| 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 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "public/web/WebPluginContainer.h" | 31 #include "public/web/WebPluginContainer.h" |
| 32 | 32 |
| 33 #include <memory> | 33 #include <memory> |
| 34 #include <string> | 34 #include <string> |
| 35 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
| 36 #include "core/events/KeyboardEvent.h" | 36 #include "core/events/KeyboardEvent.h" |
| 37 #include "core/exported/WebPluginContainerBase.h" |
| 37 #include "core/exported/WebViewBase.h" | 38 #include "core/exported/WebViewBase.h" |
| 38 #include "core/frame/EventHandlerRegistry.h" | 39 #include "core/frame/EventHandlerRegistry.h" |
| 39 #include "core/layout/LayoutObject.h" | 40 #include "core/layout/LayoutObject.h" |
| 40 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
| 41 #include "platform/graphics/GraphicsContext.h" | 42 #include "platform/graphics/GraphicsContext.h" |
| 42 #include "platform/graphics/paint/CullRect.h" | 43 #include "platform/graphics/paint/CullRect.h" |
| 43 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 44 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
| 44 #include "platform/graphics/paint/PaintController.h" | 45 #include "platform/graphics/paint/PaintController.h" |
| 45 #include "platform/graphics/paint/PaintRecorder.h" | 46 #include "platform/graphics/paint/PaintRecorder.h" |
| 46 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 47 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 #include "public/platform/WebURLLoaderMockFactory.h" | 58 #include "public/platform/WebURLLoaderMockFactory.h" |
| 58 #include "public/web/WebDocument.h" | 59 #include "public/web/WebDocument.h" |
| 59 #include "public/web/WebElement.h" | 60 #include "public/web/WebElement.h" |
| 60 #include "public/web/WebFrameClient.h" | 61 #include "public/web/WebFrameClient.h" |
| 61 #include "public/web/WebPluginParams.h" | 62 #include "public/web/WebPluginParams.h" |
| 62 #include "public/web/WebPrintParams.h" | 63 #include "public/web/WebPrintParams.h" |
| 63 #include "public/web/WebSettings.h" | 64 #include "public/web/WebSettings.h" |
| 64 #include "public/web/WebView.h" | 65 #include "public/web/WebView.h" |
| 65 #include "testing/gtest/include/gtest/gtest.h" | 66 #include "testing/gtest/include/gtest/gtest.h" |
| 66 #include "web/WebLocalFrameImpl.h" | 67 #include "web/WebLocalFrameImpl.h" |
| 67 #include "web/WebPluginContainerImpl.h" | |
| 68 #include "web/tests/FakeWebPlugin.h" | 68 #include "web/tests/FakeWebPlugin.h" |
| 69 #include "web/tests/FrameTestHelpers.h" | 69 #include "web/tests/FrameTestHelpers.h" |
| 70 | 70 |
| 71 using blink::testing::RunPendingTasks; | 71 using blink::testing::RunPendingTasks; |
| 72 | 72 |
| 73 namespace blink { | 73 namespace blink { |
| 74 | 74 |
| 75 class WebPluginContainerTest : public ::testing::Test { | 75 class WebPluginContainerTest : public ::testing::Test { |
| 76 public: | 76 public: |
| 77 WebPluginContainerTest() : base_url_("http://www.test.com/") {} | 77 WebPluginContainerTest() : base_url_("http://www.test.com/") {} |
| 78 | 78 |
| 79 void TearDown() override { | 79 void TearDown() override { |
| 80 Platform::Current() | 80 Platform::Current() |
| 81 ->GetURLLoaderMockFactory() | 81 ->GetURLLoaderMockFactory() |
| 82 ->UnregisterAllURLsAndClearMemoryCache(); | 82 ->UnregisterAllURLsAndClearMemoryCache(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CalculateGeometry(WebPluginContainerImpl* plugin_container_impl, | 85 void CalculateGeometry(WebPluginContainerBase* plugin_container_impl, |
| 86 IntRect& window_rect, | 86 IntRect& window_rect, |
| 87 IntRect& clip_rect, | 87 IntRect& clip_rect, |
| 88 IntRect& unobscured_rect) { | 88 IntRect& unobscured_rect) { |
| 89 plugin_container_impl->CalculateGeometry(window_rect, clip_rect, | 89 plugin_container_impl->CalculateGeometry(window_rect, clip_rect, |
| 90 unobscured_rect); | 90 unobscured_rect); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void RegisterMockedURL( | 93 void RegisterMockedURL( |
| 94 const std::string& file_name, | 94 const std::string& file_name, |
| 95 const std::string& mime_type = std::string("text/html")) { | 95 const std::string& mime_type = std::string("text/html")) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 #if OS(MACOSX) | 416 #if OS(MACOSX) |
| 417 modifier_key = static_cast<WebInputEvent::Modifiers>( | 417 modifier_key = static_cast<WebInputEvent::Modifiers>( |
| 418 WebInputEvent::kMetaKey | WebInputEvent::kNumLockOn | | 418 WebInputEvent::kMetaKey | WebInputEvent::kNumLockOn | |
| 419 WebInputEvent::kIsLeft); | 419 WebInputEvent::kIsLeft); |
| 420 #endif | 420 #endif |
| 421 WebKeyboardEvent web_keyboard_event_c(WebInputEvent::kRawKeyDown, | 421 WebKeyboardEvent web_keyboard_event_c(WebInputEvent::kRawKeyDown, |
| 422 modifier_key, | 422 modifier_key, |
| 423 WebInputEvent::kTimeStampForTesting); | 423 WebInputEvent::kTimeStampForTesting); |
| 424 web_keyboard_event_c.windows_key_code = 67; | 424 web_keyboard_event_c.windows_key_code = 67; |
| 425 KeyboardEvent* key_event_c = KeyboardEvent::Create(web_keyboard_event_c, 0); | 425 KeyboardEvent* key_event_c = KeyboardEvent::Create(web_keyboard_event_c, 0); |
| 426 ToWebPluginContainerImpl(plugin_container_one_element.PluginContainer()) | 426 ToWebPluginContainerBase(plugin_container_one_element.PluginContainer()) |
| 427 ->HandleEvent(key_event_c); | 427 ->HandleEvent(key_event_c); |
| 428 EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText( | 428 EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText( |
| 429 WebClipboard::Buffer())); | 429 WebClipboard::Buffer())); |
| 430 | 430 |
| 431 // Clearing |Clipboard::Buffer()|. | 431 // Clearing |Clipboard::Buffer()|. |
| 432 Platform::Current()->Clipboard()->WritePlainText(WebString("")); | 432 Platform::Current()->Clipboard()->WritePlainText(WebString("")); |
| 433 EXPECT_EQ(WebString(""), Platform::Current()->Clipboard()->ReadPlainText( | 433 EXPECT_EQ(WebString(""), Platform::Current()->Clipboard()->ReadPlainText( |
| 434 WebClipboard::Buffer())); | 434 WebClipboard::Buffer())); |
| 435 | 435 |
| 436 WebKeyboardEvent web_keyboard_event_insert( | 436 WebKeyboardEvent web_keyboard_event_insert( |
| 437 WebInputEvent::kRawKeyDown, modifier_key, | 437 WebInputEvent::kRawKeyDown, modifier_key, |
| 438 WebInputEvent::kTimeStampForTesting); | 438 WebInputEvent::kTimeStampForTesting); |
| 439 web_keyboard_event_insert.windows_key_code = 45; | 439 web_keyboard_event_insert.windows_key_code = 45; |
| 440 KeyboardEvent* key_event_insert = | 440 KeyboardEvent* key_event_insert = |
| 441 KeyboardEvent::Create(web_keyboard_event_insert, 0); | 441 KeyboardEvent::Create(web_keyboard_event_insert, 0); |
| 442 ToWebPluginContainerImpl(plugin_container_one_element.PluginContainer()) | 442 ToWebPluginContainerBase(plugin_container_one_element.PluginContainer()) |
| 443 ->HandleEvent(key_event_insert); | 443 ->HandleEvent(key_event_insert); |
| 444 EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText( | 444 EXPECT_EQ(WebString("x"), Platform::Current()->Clipboard()->ReadPlainText( |
| 445 WebClipboard::Buffer())); | 445 WebClipboard::Buffer())); |
| 446 } | 446 } |
| 447 | 447 |
| 448 // A class to facilitate testing that events are correctly received by plugins. | 448 // A class to facilitate testing that events are correctly received by plugins. |
| 449 class EventTestPlugin : public FakeWebPlugin { | 449 class EventTestPlugin : public FakeWebPlugin { |
| 450 public: | 450 public: |
| 451 explicit EventTestPlugin(const WebPluginParams& params) | 451 explicit EventTestPlugin(const WebPluginParams& params) |
| 452 : FakeWebPlugin(params), last_event_type_(WebInputEvent::kUndefined) {} | 452 : FakeWebPlugin(params), last_event_type_(WebInputEvent::kUndefined) {} |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); | 499 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); |
| 500 DCHECK(web_view); | 500 DCHECK(web_view); |
| 501 web_view->GetSettings()->SetPluginsEnabled(true); | 501 web_view->GetSettings()->SetPluginsEnabled(true); |
| 502 web_view->Resize(WebSize(300, 300)); | 502 web_view->Resize(WebSize(300, 300)); |
| 503 web_view->UpdateAllLifecyclePhases(); | 503 web_view->UpdateAllLifecyclePhases(); |
| 504 RunPendingTasks(); | 504 RunPendingTasks(); |
| 505 | 505 |
| 506 WebElement plugin_container_one_element = | 506 WebElement plugin_container_one_element = |
| 507 web_view->MainFrame()->GetDocument().GetElementById( | 507 web_view->MainFrame()->GetDocument().GetElementById( |
| 508 WebString::FromUTF8("translated-plugin")); | 508 WebString::FromUTF8("translated-plugin")); |
| 509 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 509 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 510 plugin_container_one_element.PluginContainer()) | 510 plugin_container_one_element.PluginContainer()) |
| 511 ->Plugin(); | 511 ->Plugin(); |
| 512 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 512 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 513 | 513 |
| 514 WebGestureEvent event(WebInputEvent::kGestureLongPress, | 514 WebGestureEvent event(WebInputEvent::kGestureLongPress, |
| 515 WebInputEvent::kNoModifiers, | 515 WebInputEvent::kNoModifiers, |
| 516 WebInputEvent::kTimeStampForTesting); | 516 WebInputEvent::kTimeStampForTesting); |
| 517 event.source_device = kWebGestureDeviceTouchscreen; | 517 event.source_device = kWebGestureDeviceTouchscreen; |
| 518 | 518 |
| 519 // First, send an event that doesn't hit the plugin to verify that the | 519 // First, send an event that doesn't hit the plugin to verify that the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 548 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); | 548 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); |
| 549 DCHECK(web_view); | 549 DCHECK(web_view); |
| 550 web_view->GetSettings()->SetPluginsEnabled(true); | 550 web_view->GetSettings()->SetPluginsEnabled(true); |
| 551 web_view->Resize(WebSize(300, 300)); | 551 web_view->Resize(WebSize(300, 300)); |
| 552 web_view->UpdateAllLifecyclePhases(); | 552 web_view->UpdateAllLifecyclePhases(); |
| 553 RunPendingTasks(); | 553 RunPendingTasks(); |
| 554 | 554 |
| 555 WebElement plugin_container_one_element = | 555 WebElement plugin_container_one_element = |
| 556 web_view->MainFrame()->GetDocument().GetElementById( | 556 web_view->MainFrame()->GetDocument().GetElementById( |
| 557 WebString::FromUTF8("translated-plugin")); | 557 WebString::FromUTF8("translated-plugin")); |
| 558 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 558 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 559 plugin_container_one_element.PluginContainer()) | 559 plugin_container_one_element.PluginContainer()) |
| 560 ->Plugin(); | 560 ->Plugin(); |
| 561 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 561 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 562 | 562 |
| 563 WebMouseWheelEvent event(WebInputEvent::kMouseWheel, | 563 WebMouseWheelEvent event(WebInputEvent::kMouseWheel, |
| 564 WebInputEvent::kNoModifiers, | 564 WebInputEvent::kNoModifiers, |
| 565 WebInputEvent::kTimeStampForTesting); | 565 WebInputEvent::kTimeStampForTesting); |
| 566 | 566 |
| 567 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 567 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 568 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); | 568 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 589 RunPendingTasks(); | 589 RunPendingTasks(); |
| 590 web_view->SmoothScroll(0, 200, 0); | 590 web_view->SmoothScroll(0, 200, 0); |
| 591 web_view->UpdateAllLifecyclePhases(); | 591 web_view->UpdateAllLifecyclePhases(); |
| 592 RunPendingTasks(); | 592 RunPendingTasks(); |
| 593 | 593 |
| 594 WebElement plugin_container_one_element = | 594 WebElement plugin_container_one_element = |
| 595 web_view->MainFrame()->GetDocument().GetElementById( | 595 web_view->MainFrame()->GetDocument().GetElementById( |
| 596 WebString::FromUTF8("scrolled-plugin")); | 596 WebString::FromUTF8("scrolled-plugin")); |
| 597 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 597 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 598 WebPluginContainer::kTouchEventRequestTypeRaw); | 598 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 599 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 599 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 600 plugin_container_one_element.PluginContainer()) | 600 plugin_container_one_element.PluginContainer()) |
| 601 ->Plugin(); | 601 ->Plugin(); |
| 602 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 602 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 603 | 603 |
| 604 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, | 604 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, |
| 605 WebInputEvent::kTimeStampForTesting); | 605 WebInputEvent::kTimeStampForTesting); |
| 606 event.touches_length = 1; | 606 event.touches_length = 1; |
| 607 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 607 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 608 event.touches[0].state = WebTouchPoint::kStatePressed; | 608 event.touches[0].state = WebTouchPoint::kStatePressed; |
| 609 event.touches[0].position = | 609 event.touches[0].position = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 631 RunPendingTasks(); | 631 RunPendingTasks(); |
| 632 web_view->SmoothScroll(0, 200, 0); | 632 web_view->SmoothScroll(0, 200, 0); |
| 633 web_view->UpdateAllLifecyclePhases(); | 633 web_view->UpdateAllLifecyclePhases(); |
| 634 RunPendingTasks(); | 634 RunPendingTasks(); |
| 635 | 635 |
| 636 WebElement plugin_container_one_element = | 636 WebElement plugin_container_one_element = |
| 637 web_view->MainFrame()->GetDocument().GetElementById( | 637 web_view->MainFrame()->GetDocument().GetElementById( |
| 638 WebString::FromUTF8("scrolled-plugin")); | 638 WebString::FromUTF8("scrolled-plugin")); |
| 639 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 639 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 640 WebPluginContainer::kTouchEventRequestTypeRaw); | 640 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 641 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 641 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 642 plugin_container_one_element.PluginContainer()) | 642 plugin_container_one_element.PluginContainer()) |
| 643 ->Plugin(); | 643 ->Plugin(); |
| 644 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 644 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 645 | 645 |
| 646 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, | 646 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, |
| 647 WebInputEvent::kTimeStampForTesting); | 647 WebInputEvent::kTimeStampForTesting); |
| 648 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 648 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 649 event.touches_length = 1; | 649 event.touches_length = 1; |
| 650 event.touches[0].state = WebTouchPoint::kStatePressed; | 650 event.touches[0].state = WebTouchPoint::kStatePressed; |
| 651 event.touches[0].position = | 651 event.touches[0].position = |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 RunPendingTasks(); | 689 RunPendingTasks(); |
| 690 web_view->SmoothScroll(0, 200, 0); | 690 web_view->SmoothScroll(0, 200, 0); |
| 691 web_view->UpdateAllLifecyclePhases(); | 691 web_view->UpdateAllLifecyclePhases(); |
| 692 RunPendingTasks(); | 692 RunPendingTasks(); |
| 693 | 693 |
| 694 WebElement plugin_container_one_element = | 694 WebElement plugin_container_one_element = |
| 695 web_view->MainFrame()->GetDocument().GetElementById( | 695 web_view->MainFrame()->GetDocument().GetElementById( |
| 696 WebString::FromUTF8("scrolled-plugin")); | 696 WebString::FromUTF8("scrolled-plugin")); |
| 697 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 697 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 698 WebPluginContainer::kTouchEventRequestTypeRaw); | 698 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 699 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 699 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 700 plugin_container_one_element.PluginContainer()) | 700 plugin_container_one_element.PluginContainer()) |
| 701 ->Plugin(); | 701 ->Plugin(); |
| 702 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 702 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 703 | 703 |
| 704 WebMouseWheelEvent event(WebInputEvent::kMouseWheel, | 704 WebMouseWheelEvent event(WebInputEvent::kMouseWheel, |
| 705 WebInputEvent::kNoModifiers, | 705 WebInputEvent::kNoModifiers, |
| 706 WebInputEvent::kTimeStampForTesting); | 706 WebInputEvent::kTimeStampForTesting); |
| 707 | 707 |
| 708 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 708 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 709 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); | 709 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 730 RunPendingTasks(); | 730 RunPendingTasks(); |
| 731 web_view->SmoothScroll(0, 200, 0); | 731 web_view->SmoothScroll(0, 200, 0); |
| 732 web_view->UpdateAllLifecyclePhases(); | 732 web_view->UpdateAllLifecyclePhases(); |
| 733 RunPendingTasks(); | 733 RunPendingTasks(); |
| 734 | 734 |
| 735 WebElement plugin_container_one_element = | 735 WebElement plugin_container_one_element = |
| 736 web_view->MainFrame()->GetDocument().GetElementById( | 736 web_view->MainFrame()->GetDocument().GetElementById( |
| 737 WebString::FromUTF8("scrolled-plugin")); | 737 WebString::FromUTF8("scrolled-plugin")); |
| 738 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 738 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 739 WebPluginContainer::kTouchEventRequestTypeRaw); | 739 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 740 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 740 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 741 plugin_container_one_element.PluginContainer()) | 741 plugin_container_one_element.PluginContainer()) |
| 742 ->Plugin(); | 742 ->Plugin(); |
| 743 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 743 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 744 | 744 |
| 745 WebMouseEvent event(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers, | 745 WebMouseEvent event(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers, |
| 746 WebInputEvent::kTimeStampForTesting); | 746 WebInputEvent::kTimeStampForTesting); |
| 747 | 747 |
| 748 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 748 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 749 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); | 749 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); |
| 750 | 750 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 769 web_view->SetPageScaleFactor(2); | 769 web_view->SetPageScaleFactor(2); |
| 770 web_view->SmoothScroll(0, 300, 0); | 770 web_view->SmoothScroll(0, 300, 0); |
| 771 web_view->UpdateAllLifecyclePhases(); | 771 web_view->UpdateAllLifecyclePhases(); |
| 772 RunPendingTasks(); | 772 RunPendingTasks(); |
| 773 | 773 |
| 774 WebElement plugin_container_one_element = | 774 WebElement plugin_container_one_element = |
| 775 web_view->MainFrame()->GetDocument().GetElementById( | 775 web_view->MainFrame()->GetDocument().GetElementById( |
| 776 WebString::FromUTF8("scrolled-plugin")); | 776 WebString::FromUTF8("scrolled-plugin")); |
| 777 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 777 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 778 WebPluginContainer::kTouchEventRequestTypeRaw); | 778 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 779 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 779 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 780 plugin_container_one_element.PluginContainer()) | 780 plugin_container_one_element.PluginContainer()) |
| 781 ->Plugin(); | 781 ->Plugin(); |
| 782 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 782 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 783 | 783 |
| 784 WebMouseEvent event(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers, | 784 WebMouseEvent event(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers, |
| 785 WebInputEvent::kTimeStampForTesting); | 785 WebInputEvent::kTimeStampForTesting); |
| 786 | 786 |
| 787 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 787 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 788 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); | 788 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); |
| 789 | 789 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 810 web_view->SetPageScaleFactor(2); | 810 web_view->SetPageScaleFactor(2); |
| 811 web_view->SmoothScroll(0, 300, 0); | 811 web_view->SmoothScroll(0, 300, 0); |
| 812 web_view->UpdateAllLifecyclePhases(); | 812 web_view->UpdateAllLifecyclePhases(); |
| 813 RunPendingTasks(); | 813 RunPendingTasks(); |
| 814 | 814 |
| 815 WebElement plugin_container_one_element = | 815 WebElement plugin_container_one_element = |
| 816 web_view->MainFrame()->GetDocument().GetElementById( | 816 web_view->MainFrame()->GetDocument().GetElementById( |
| 817 WebString::FromUTF8("scrolled-plugin")); | 817 WebString::FromUTF8("scrolled-plugin")); |
| 818 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 818 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 819 WebPluginContainer::kTouchEventRequestTypeRaw); | 819 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 820 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 820 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 821 plugin_container_one_element.PluginContainer()) | 821 plugin_container_one_element.PluginContainer()) |
| 822 ->Plugin(); | 822 ->Plugin(); |
| 823 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 823 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 824 | 824 |
| 825 WebMouseWheelEvent event(WebInputEvent::kMouseWheel, | 825 WebMouseWheelEvent event(WebInputEvent::kMouseWheel, |
| 826 WebInputEvent::kNoModifiers, | 826 WebInputEvent::kNoModifiers, |
| 827 WebInputEvent::kTimeStampForTesting); | 827 WebInputEvent::kTimeStampForTesting); |
| 828 | 828 |
| 829 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 829 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 830 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); | 830 event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 852 web_view->SetPageScaleFactor(2); | 852 web_view->SetPageScaleFactor(2); |
| 853 web_view->SmoothScroll(0, 300, 0); | 853 web_view->SmoothScroll(0, 300, 0); |
| 854 web_view->UpdateAllLifecyclePhases(); | 854 web_view->UpdateAllLifecyclePhases(); |
| 855 RunPendingTasks(); | 855 RunPendingTasks(); |
| 856 | 856 |
| 857 WebElement plugin_container_one_element = | 857 WebElement plugin_container_one_element = |
| 858 web_view->MainFrame()->GetDocument().GetElementById( | 858 web_view->MainFrame()->GetDocument().GetElementById( |
| 859 WebString::FromUTF8("scrolled-plugin")); | 859 WebString::FromUTF8("scrolled-plugin")); |
| 860 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 860 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
| 861 WebPluginContainer::kTouchEventRequestTypeRaw); | 861 WebPluginContainer::kTouchEventRequestTypeRaw); |
| 862 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>( | 862 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
| 863 plugin_container_one_element.PluginContainer()) | 863 plugin_container_one_element.PluginContainer()) |
| 864 ->Plugin(); | 864 ->Plugin(); |
| 865 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 865 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
| 866 | 866 |
| 867 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, | 867 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, |
| 868 WebInputEvent::kTimeStampForTesting); | 868 WebInputEvent::kTimeStampForTesting); |
| 869 event.touches_length = 1; | 869 event.touches_length = 1; |
| 870 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 870 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
| 871 | 871 |
| 872 event.touches[0].state = WebTouchPoint::kStatePressed; | 872 event.touches[0].state = WebTouchPoint::kStatePressed; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 890 plugin_web_frame_client; // Must outlive webViewHelper. | 890 plugin_web_frame_client; // Must outlive webViewHelper. |
| 891 FrameTestHelpers::WebViewHelper web_view_helper; | 891 FrameTestHelpers::WebViewHelper web_view_helper; |
| 892 WebView* web_view = web_view_helper.InitializeAndLoad( | 892 WebView* web_view = web_view_helper.InitializeAndLoad( |
| 893 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); | 893 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); |
| 894 DCHECK(web_view); | 894 DCHECK(web_view); |
| 895 web_view->GetSettings()->SetPluginsEnabled(true); | 895 web_view->GetSettings()->SetPluginsEnabled(true); |
| 896 web_view->Resize(WebSize(300, 300)); | 896 web_view->Resize(WebSize(300, 300)); |
| 897 web_view->UpdateAllLifecyclePhases(); | 897 web_view->UpdateAllLifecyclePhases(); |
| 898 RunPendingTasks(); | 898 RunPendingTasks(); |
| 899 | 899 |
| 900 WebPluginContainerImpl* plugin_container_impl = | 900 WebPluginContainerBase* plugin_container_impl = |
| 901 ToWebPluginContainerImpl(GetWebPluginContainer( | 901 ToWebPluginContainerBase(GetWebPluginContainer( |
| 902 web_view, WebString::FromUTF8("translated-plugin"))); | 902 web_view, WebString::FromUTF8("translated-plugin"))); |
| 903 plugin_container_impl->SetFrameRect(IntRect(0, 0, 300, 300)); | 903 plugin_container_impl->SetFrameRect(IntRect(0, 0, 300, 300)); |
| 904 | 904 |
| 905 WebRect rect = plugin_container_impl->GetElement().BoundsInViewport(); | 905 WebRect rect = plugin_container_impl->GetElement().BoundsInViewport(); |
| 906 EXPECT_TRUE(plugin_container_impl->IsRectTopmost(rect)); | 906 EXPECT_TRUE(plugin_container_impl->IsRectTopmost(rect)); |
| 907 | 907 |
| 908 // Cause the plugin's frame to be detached. | 908 // Cause the plugin's frame to be detached. |
| 909 web_view_helper.Reset(); | 909 web_view_helper.Reset(); |
| 910 | 910 |
| 911 EXPECT_FALSE(plugin_container_impl->IsRectTopmost(rect)); | 911 EXPECT_FALSE(plugin_container_impl->IsRectTopmost(rect)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 932 &plugin_web_frame_client); | 932 &plugin_web_frame_client); |
| 933 DCHECK(web_view); | 933 DCHECK(web_view); |
| 934 web_view->GetSettings()->SetPluginsEnabled(true); | 934 web_view->GetSettings()->SetPluginsEnabled(true); |
| 935 web_view->Resize(WebSize(300, 300)); | 935 web_view->Resize(WebSize(300, 300)); |
| 936 web_view->UpdateAllLifecyclePhases(); | 936 web_view->UpdateAllLifecyclePhases(); |
| 937 RunPendingTasks(); | 937 RunPendingTasks(); |
| 938 | 938 |
| 939 WebElement plugin_element = | 939 WebElement plugin_element = |
| 940 web_view->MainFrame()->FirstChild()->GetDocument().GetElementById( | 940 web_view->MainFrame()->FirstChild()->GetDocument().GetElementById( |
| 941 "translated-plugin"); | 941 "translated-plugin"); |
| 942 WebPluginContainerImpl* plugin_container_impl = | 942 WebPluginContainerBase* plugin_container_impl = |
| 943 ToWebPluginContainerImpl(plugin_element.PluginContainer()); | 943 ToWebPluginContainerBase(plugin_element.PluginContainer()); |
| 944 | 944 |
| 945 DCHECK(plugin_container_impl); | 945 DCHECK(plugin_container_impl); |
| 946 | 946 |
| 947 IntRect window_rect, clip_rect, unobscured_rect; | 947 IntRect window_rect, clip_rect, unobscured_rect; |
| 948 Vector<IntRect> cut_out_rects; | 948 Vector<IntRect> cut_out_rects; |
| 949 CalculateGeometry(plugin_container_impl, window_rect, clip_rect, | 949 CalculateGeometry(plugin_container_impl, window_rect, clip_rect, |
| 950 unobscured_rect); | 950 unobscured_rect); |
| 951 EXPECT_RECT_EQ(IntRect(20, 220, 40, 40), window_rect); | 951 EXPECT_RECT_EQ(IntRect(20, 220, 40, 40), window_rect); |
| 952 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), clip_rect); | 952 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), clip_rect); |
| 953 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), unobscured_rect); | 953 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), unobscured_rect); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 966 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); | 966 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); |
| 967 DCHECK(web_view); | 967 DCHECK(web_view); |
| 968 web_view->GetSettings()->SetPluginsEnabled(true); | 968 web_view->GetSettings()->SetPluginsEnabled(true); |
| 969 web_view->Resize(WebSize(300, 300)); | 969 web_view->Resize(WebSize(300, 300)); |
| 970 web_view->UpdateAllLifecyclePhases(); | 970 web_view->UpdateAllLifecyclePhases(); |
| 971 RunPendingTasks(); | 971 RunPendingTasks(); |
| 972 | 972 |
| 973 WebElement plugin_element = | 973 WebElement plugin_element = |
| 974 web_view->MainFrame()->GetDocument().GetElementById( | 974 web_view->MainFrame()->GetDocument().GetElementById( |
| 975 "subpixel-positioned-plugin"); | 975 "subpixel-positioned-plugin"); |
| 976 WebPluginContainerImpl* plugin_container_impl = | 976 WebPluginContainerBase* plugin_container_impl = |
| 977 ToWebPluginContainerImpl(plugin_element.PluginContainer()); | 977 ToWebPluginContainerBase(plugin_element.PluginContainer()); |
| 978 | 978 |
| 979 DCHECK(plugin_container_impl); | 979 DCHECK(plugin_container_impl); |
| 980 | 980 |
| 981 IntRect window_rect, clip_rect, unobscured_rect; | 981 IntRect window_rect, clip_rect, unobscured_rect; |
| 982 Vector<IntRect> cut_out_rects; | 982 Vector<IntRect> cut_out_rects; |
| 983 | 983 |
| 984 CalculateGeometry(plugin_container_impl, window_rect, clip_rect, | 984 CalculateGeometry(plugin_container_impl, window_rect, clip_rect, |
| 985 unobscured_rect); | 985 unobscured_rect); |
| 986 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), window_rect); | 986 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), window_rect); |
| 987 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), clip_rect); | 987 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), clip_rect); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1014 CustomPluginWebFrameClient<TopmostPlugin> plugin_web_frame_client; | 1014 CustomPluginWebFrameClient<TopmostPlugin> plugin_web_frame_client; |
| 1015 FrameTestHelpers::WebViewHelper web_view_helper; | 1015 FrameTestHelpers::WebViewHelper web_view_helper; |
| 1016 WebView* web_view = web_view_helper.InitializeAndLoad( | 1016 WebView* web_view = web_view_helper.InitializeAndLoad( |
| 1017 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); | 1017 base_url_ + "plugin_container.html", true, &plugin_web_frame_client); |
| 1018 DCHECK(web_view); | 1018 DCHECK(web_view); |
| 1019 web_view->GetSettings()->SetPluginsEnabled(true); | 1019 web_view->GetSettings()->SetPluginsEnabled(true); |
| 1020 web_view->Resize(WebSize(300, 300)); | 1020 web_view->Resize(WebSize(300, 300)); |
| 1021 web_view->UpdateAllLifecyclePhases(); | 1021 web_view->UpdateAllLifecyclePhases(); |
| 1022 RunPendingTasks(); | 1022 RunPendingTasks(); |
| 1023 | 1023 |
| 1024 WebPluginContainerImpl* plugin_container_impl = | 1024 WebPluginContainerBase* plugin_container_impl = |
| 1025 ToWebPluginContainerImpl(GetWebPluginContainer( | 1025 ToWebPluginContainerBase(GetWebPluginContainer( |
| 1026 web_view, WebString::FromUTF8("translated-plugin"))); | 1026 web_view, WebString::FromUTF8("translated-plugin"))); |
| 1027 plugin_container_impl->SetFrameRect(IntRect(0, 0, 300, 300)); | 1027 plugin_container_impl->SetFrameRect(IntRect(0, 0, 300, 300)); |
| 1028 | 1028 |
| 1029 EXPECT_TRUE(plugin_container_impl->IsRectTopmost(topmost_rect)); | 1029 EXPECT_TRUE(plugin_container_impl->IsRectTopmost(topmost_rect)); |
| 1030 | 1030 |
| 1031 TopmostPlugin* test_plugin = | 1031 TopmostPlugin* test_plugin = |
| 1032 static_cast<TopmostPlugin*>(plugin_container_impl->Plugin()); | 1032 static_cast<TopmostPlugin*>(plugin_container_impl->Plugin()); |
| 1033 EXPECT_TRUE(test_plugin->IsRectTopmost()); | 1033 EXPECT_TRUE(test_plugin->IsRectTopmost()); |
| 1034 | 1034 |
| 1035 // Cause the plugin's frame to be detached. | 1035 // Cause the plugin's frame to be detached. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 CustomPluginWebFrameClient<CompositedPlugin> web_frame_client; | 1074 CustomPluginWebFrameClient<CompositedPlugin> web_frame_client; |
| 1075 FrameTestHelpers::WebViewHelper web_view_helper; | 1075 FrameTestHelpers::WebViewHelper web_view_helper; |
| 1076 WebView* web_view = web_view_helper.InitializeAndLoad( | 1076 WebView* web_view = web_view_helper.InitializeAndLoad( |
| 1077 base_url_ + "plugin.html", true, &web_frame_client); | 1077 base_url_ + "plugin.html", true, &web_frame_client); |
| 1078 ASSERT_TRUE(web_view); | 1078 ASSERT_TRUE(web_view); |
| 1079 web_view->GetSettings()->SetPluginsEnabled(true); | 1079 web_view->GetSettings()->SetPluginsEnabled(true); |
| 1080 web_view->Resize(WebSize(800, 600)); | 1080 web_view->Resize(WebSize(800, 600)); |
| 1081 web_view->UpdateAllLifecyclePhases(); | 1081 web_view->UpdateAllLifecyclePhases(); |
| 1082 RunPendingTasks(); | 1082 RunPendingTasks(); |
| 1083 | 1083 |
| 1084 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>( | 1084 WebPluginContainerBase* container = static_cast<WebPluginContainerBase*>( |
| 1085 GetWebPluginContainer(web_view, WebString::FromUTF8("plugin"))); | 1085 GetWebPluginContainer(web_view, WebString::FromUTF8("plugin"))); |
| 1086 ASSERT_TRUE(container); | 1086 ASSERT_TRUE(container); |
| 1087 Element* element = static_cast<Element*>(container->GetElement()); | 1087 Element* element = static_cast<Element*>(container->GetElement()); |
| 1088 const auto* plugin = | 1088 const auto* plugin = |
| 1089 static_cast<const CompositedPlugin*>(container->Plugin()); | 1089 static_cast<const CompositedPlugin*>(container->Plugin()); |
| 1090 | 1090 |
| 1091 std::unique_ptr<PaintController> paint_controller = PaintController::Create(); | 1091 std::unique_ptr<PaintController> paint_controller = PaintController::Create(); |
| 1092 PropertyTreeState property_tree_state(TransformPaintPropertyNode::Root(), | 1092 PropertyTreeState property_tree_state(TransformPaintPropertyNode::Root(), |
| 1093 ClipPaintPropertyNode::Root(), | 1093 ClipPaintPropertyNode::Root(), |
| 1094 EffectPaintPropertyNode::Root()); | 1094 EffectPaintPropertyNode::Root()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 web_view->MainFrame()->GetDocument().GetElementById( | 1127 web_view->MainFrame()->GetDocument().GetElementById( |
| 1128 WebString::FromUTF8("translated-plugin")); | 1128 WebString::FromUTF8("translated-plugin")); |
| 1129 plugin_container_one_element.PluginContainer()->SetWantsWheelEvents(true); | 1129 plugin_container_one_element.PluginContainer()->SetWantsWheelEvents(true); |
| 1130 | 1130 |
| 1131 RunPendingTasks(); | 1131 RunPendingTasks(); |
| 1132 EXPECT_TRUE(web_view->GetPage()->GetEventHandlerRegistry().HasEventHandlers( | 1132 EXPECT_TRUE(web_view->GetPage()->GetEventHandlerRegistry().HasEventHandlers( |
| 1133 EventHandlerRegistry::kWheelEventBlocking)); | 1133 EventHandlerRegistry::kWheelEventBlocking)); |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 } // namespace blink | 1136 } // namespace blink |
| OLD | NEW |