| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "public/web/WebPrintParams.h" | 59 #include "public/web/WebPrintParams.h" |
| 60 #include "public/web/WebSettings.h" | 60 #include "public/web/WebSettings.h" |
| 61 #include "public/web/WebView.h" | 61 #include "public/web/WebView.h" |
| 62 #include "testing/gtest/include/gtest/gtest.h" | 62 #include "testing/gtest/include/gtest/gtest.h" |
| 63 #include "third_party/skia/include/core/SkPictureRecorder.h" | 63 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 64 #include "web/WebLocalFrameImpl.h" | 64 #include "web/WebLocalFrameImpl.h" |
| 65 #include "web/WebPluginContainerImpl.h" | 65 #include "web/WebPluginContainerImpl.h" |
| 66 #include "web/WebViewImpl.h" | 66 #include "web/WebViewImpl.h" |
| 67 #include "web/tests/FakeWebPlugin.h" | 67 #include "web/tests/FakeWebPlugin.h" |
| 68 #include "web/tests/FrameTestHelpers.h" | 68 #include "web/tests/FrameTestHelpers.h" |
| 69 #include "wtf/PtrUtil.h" | |
| 70 #include <memory> | |
| 71 | 69 |
| 72 using blink::testing::runPendingTasks; | 70 using blink::testing::runPendingTasks; |
| 73 | 71 |
| 74 namespace blink { | 72 namespace blink { |
| 75 | 73 |
| 76 class WebPluginContainerTest : public ::testing::Test { | 74 class WebPluginContainerTest : public ::testing::Test { |
| 77 public: | 75 public: |
| 78 WebPluginContainerTest() | 76 WebPluginContainerTest() |
| 79 : m_baseURL("http://www.test.com/") | 77 : m_baseURL("http://www.test.com/") |
| 80 { | 78 { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 595 |
| 598 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); | 596 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| 599 } | 597 } |
| 600 | 598 |
| 601 namespace { | 599 namespace { |
| 602 | 600 |
| 603 class CompositedPlugin : public FakeWebPlugin { | 601 class CompositedPlugin : public FakeWebPlugin { |
| 604 public: | 602 public: |
| 605 CompositedPlugin(WebLocalFrame* frame, const WebPluginParams& params) | 603 CompositedPlugin(WebLocalFrame* frame, const WebPluginParams& params) |
| 606 : FakeWebPlugin(frame, params) | 604 : FakeWebPlugin(frame, params) |
| 607 , m_layer(wrapUnique(Platform::current()->compositorSupport()->createLay
er())) | 605 , m_layer(adoptPtr(Platform::current()->compositorSupport()->createLayer
())) |
| 608 { | 606 { |
| 609 } | 607 } |
| 610 | 608 |
| 611 WebLayer* getWebLayer() const { return m_layer.get(); } | 609 WebLayer* getWebLayer() const { return m_layer.get(); } |
| 612 | 610 |
| 613 // WebPlugin | 611 // WebPlugin |
| 614 | 612 |
| 615 bool initialize(WebPluginContainer* container) override | 613 bool initialize(WebPluginContainer* container) override |
| 616 { | 614 { |
| 617 if (!FakeWebPlugin::initialize(container)) | 615 if (!FakeWebPlugin::initialize(container)) |
| 618 return false; | 616 return false; |
| 619 container->setWebLayer(m_layer.get()); | 617 container->setWebLayer(m_layer.get()); |
| 620 return true; | 618 return true; |
| 621 } | 619 } |
| 622 | 620 |
| 623 void destroy() override | 621 void destroy() override |
| 624 { | 622 { |
| 625 container()->setWebLayer(nullptr); | 623 container()->setWebLayer(nullptr); |
| 626 FakeWebPlugin::destroy(); | 624 FakeWebPlugin::destroy(); |
| 627 } | 625 } |
| 628 | 626 |
| 629 private: | 627 private: |
| 630 std::unique_ptr<WebLayer> m_layer; | 628 OwnPtr<WebLayer> m_layer; |
| 631 }; | 629 }; |
| 632 | 630 |
| 633 class ScopedSPv2 { | 631 class ScopedSPv2 { |
| 634 public: | 632 public: |
| 635 ScopedSPv2() { RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); } | 633 ScopedSPv2() { RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); } |
| 636 ~ScopedSPv2() { m_featuresBackup.restore(); } | 634 ~ScopedSPv2() { m_featuresBackup.restore(); } |
| 637 private: | 635 private: |
| 638 RuntimeEnabledFeatures::Backup m_featuresBackup; | 636 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 639 }; | 637 }; |
| 640 | 638 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 651 webView->settings()->setPluginsEnabled(true); | 649 webView->settings()->setPluginsEnabled(true); |
| 652 webView->resize(WebSize(800, 600)); | 650 webView->resize(WebSize(800, 600)); |
| 653 webView->updateAllLifecyclePhases(); | 651 webView->updateAllLifecyclePhases(); |
| 654 runPendingTasks(); | 652 runPendingTasks(); |
| 655 | 653 |
| 656 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(get
WebPluginContainer(webView, WebString::fromUTF8("plugin"))); | 654 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(get
WebPluginContainer(webView, WebString::fromUTF8("plugin"))); |
| 657 ASSERT_TRUE(container); | 655 ASSERT_TRUE(container); |
| 658 Element* element = static_cast<Element*>(container->element()); | 656 Element* element = static_cast<Element*>(container->element()); |
| 659 const auto* plugin = static_cast<const CompositedPlugin*>(container->plugin(
)); | 657 const auto* plugin = static_cast<const CompositedPlugin*>(container->plugin(
)); |
| 660 | 658 |
| 661 std::unique_ptr<PaintController> paintController = PaintController::create()
; | 659 OwnPtr<PaintController> paintController = PaintController::create(); |
| 662 GraphicsContext graphicsContext(*paintController); | 660 GraphicsContext graphicsContext(*paintController); |
| 663 container->paint(graphicsContext, CullRect(IntRect(10, 10, 400, 300))); | 661 container->paint(graphicsContext, CullRect(IntRect(10, 10, 400, 300))); |
| 664 paintController->commitNewDisplayItems(); | 662 paintController->commitNewDisplayItems(); |
| 665 | 663 |
| 666 const auto& displayItems = paintController->paintArtifact().getDisplayItemLi
st(); | 664 const auto& displayItems = paintController->paintArtifact().getDisplayItemLi
st(); |
| 667 ASSERT_EQ(1u, displayItems.size()); | 665 ASSERT_EQ(1u, displayItems.size()); |
| 668 EXPECT_EQ(element->layoutObject(), &displayItems[0].client()); | 666 EXPECT_EQ(element->layoutObject(), &displayItems[0].client()); |
| 669 ASSERT_EQ(DisplayItem::ForeignLayerPlugin, displayItems[0].getType()); | 667 ASSERT_EQ(DisplayItem::ForeignLayerPlugin, displayItems[0].getType()); |
| 670 const auto& foreignLayerDisplayItem = static_cast<const ForeignLayerDisplayI
tem&>(displayItems[0]); | 668 const auto& foreignLayerDisplayItem = static_cast<const ForeignLayerDisplayI
tem&>(displayItems[0]); |
| 671 EXPECT_EQ(plugin->getWebLayer()->ccLayer(), foreignLayerDisplayItem.layer())
; | 669 EXPECT_EQ(plugin->getWebLayer()->ccLayer(), foreignLayerDisplayItem.layer())
; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 686 runPendingTasks(); | 684 runPendingTasks(); |
| 687 | 685 |
| 688 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 686 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 689 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 687 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 690 | 688 |
| 691 runPendingTasks(); | 689 runPendingTasks(); |
| 692 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); | 690 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); |
| 693 } | 691 } |
| 694 | 692 |
| 695 } // namespace blink | 693 } // namespace blink |
| OLD | NEW |