| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 webView->resize(WebSize(300, 300)); | 330 webView->resize(WebSize(300, 300)); |
| 331 webView->updateAllLifecyclePhases(); | 331 webView->updateAllLifecyclePhases(); |
| 332 runPendingTasks(); | 332 runPendingTasks(); |
| 333 | 333 |
| 334 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 334 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 335 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 335 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); |
| 336 #if OS(MACOSX) | 336 #if OS(MACOSX) |
| 337 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 337 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); |
| 338 #endif | 338 #endif |
| 339 PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "",
"", "67", "", "", 67, 0, false, modifierKey, 0.0); | 339 PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "",
"", "67", "", "", 67, 0, false, modifierKey, 0.0); |
| 340 RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platform
KeyboardEventC, 0); | 340 RawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEven
tC, 0); |
| 341 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventC.get()); | 341 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventC.get()); |
| 342 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 342 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 343 | 343 |
| 344 // Clearing |Clipboard::Buffer()|. | 344 // Clearing |Clipboard::Buffer()|. |
| 345 Platform::current()->clipboard()->writePlainText(WebString("")); | 345 Platform::current()->clipboard()->writePlainText(WebString("")); |
| 346 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); | 346 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); |
| 347 | 347 |
| 348 PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown,
"", "", "45", "", "", 45, 0, false, modifierKey, 0.0); | 348 PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown,
"", "", "45", "", "", 45, 0, false, modifierKey, 0.0); |
| 349 RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(pla
tformKeyboardEventInsert, 0); | 349 RawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboar
dEventInsert, 0); |
| 350 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventInsert.get()); | 350 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventInsert.get()); |
| 351 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 351 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 352 } | 352 } |
| 353 | 353 |
| 354 // A class to facilitate testing that events are correctly received by plugins. | 354 // A class to facilitate testing that events are correctly received by plugins. |
| 355 class EventTestPlugin : public FakeWebPlugin { | 355 class EventTestPlugin : public FakeWebPlugin { |
| 356 public: | 356 public: |
| 357 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) | 357 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) |
| 358 : FakeWebPlugin(frame, params) | 358 : FakeWebPlugin(frame, params) |
| 359 , m_lastEventType(WebInputEvent::Undefined) | 359 , m_lastEventType(WebInputEvent::Undefined) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 420 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 421 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 421 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 422 FrameTestHelpers::WebViewHelper webViewHelper; | 422 FrameTestHelpers::WebViewHelper webViewHelper; |
| 423 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 423 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 424 ASSERT(webView); | 424 ASSERT(webView); |
| 425 webView->settings()->setPluginsEnabled(true); | 425 webView->settings()->setPluginsEnabled(true); |
| 426 webView->resize(WebSize(300, 300)); | 426 webView->resize(WebSize(300, 300)); |
| 427 webView->updateAllLifecyclePhases(); | 427 webView->updateAllLifecyclePhases(); |
| 428 runPendingTasks(); | 428 runPendingTasks(); |
| 429 | 429 |
| 430 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = | 430 RawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 431 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 431 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 432 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 432 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 433 | 433 |
| 434 WebRect rect = pluginContainerImpl->element().boundsInViewport(); | 434 WebRect rect = pluginContainerImpl->element().boundsInViewport(); |
| 435 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); | 435 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); |
| 436 | 436 |
| 437 // Cause the plugin's frame to be detached. | 437 // Cause the plugin's frame to be detached. |
| 438 webViewHelper.reset(); | 438 webViewHelper.reset(); |
| 439 | 439 |
| 440 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); | 440 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 457 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 457 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 458 FrameTestHelpers::WebViewHelper webViewHelper; | 458 FrameTestHelpers::WebViewHelper webViewHelper; |
| 459 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); | 459 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); |
| 460 ASSERT(webView); | 460 ASSERT(webView); |
| 461 webView->settings()->setPluginsEnabled(true); | 461 webView->settings()->setPluginsEnabled(true); |
| 462 webView->resize(WebSize(300, 300)); | 462 webView->resize(WebSize(300, 300)); |
| 463 webView->updateAllLifecyclePhases(); | 463 webView->updateAllLifecyclePhases(); |
| 464 runPendingTasks(); | 464 runPendingTasks(); |
| 465 | 465 |
| 466 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); | 466 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); |
| 467 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPlugin
ContainerImpl(pluginElement.pluginContainer()); | 467 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); |
| 468 | 468 |
| 469 ASSERT(pluginContainerImpl.get()); | 469 ASSERT(pluginContainerImpl.get()); |
| 470 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 470 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 471 | 471 |
| 472 IntRect windowRect, clipRect, unobscuredRect; | 472 IntRect windowRect, clipRect, unobscuredRect; |
| 473 Vector<IntRect> cutOutRects; | 473 Vector<IntRect> cutOutRects; |
| 474 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); | 474 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); |
| 475 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); | 475 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); |
| 476 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); | 476 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); |
| 477 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); | 477 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); |
| 478 | 478 |
| 479 // Cause the plugin's frame to be detached. | 479 // Cause the plugin's frame to be detached. |
| 480 webViewHelper.reset(); | 480 webViewHelper.reset(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) | 483 TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) |
| 484 { | 484 { |
| 485 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 485 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 486 | 486 |
| 487 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 487 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 488 FrameTestHelpers::WebViewHelper webViewHelper; | 488 FrameTestHelpers::WebViewHelper webViewHelper; |
| 489 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 489 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 490 ASSERT(webView); | 490 ASSERT(webView); |
| 491 webView->settings()->setPluginsEnabled(true); | 491 webView->settings()->setPluginsEnabled(true); |
| 492 webView->resize(WebSize(300, 300)); | 492 webView->resize(WebSize(300, 300)); |
| 493 webView->updateAllLifecyclePhases(); | 493 webView->updateAllLifecyclePhases(); |
| 494 runPendingTasks(); | 494 runPendingTasks(); |
| 495 | 495 |
| 496 WebElement pluginElement = webView->mainFrame()->document().getElementById("
subpixel-positioned-plugin"); | 496 WebElement pluginElement = webView->mainFrame()->document().getElementById("
subpixel-positioned-plugin"); |
| 497 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPlugin
ContainerImpl(pluginElement.pluginContainer()); | 497 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); |
| 498 | 498 |
| 499 ASSERT(pluginContainerImpl.get()); | 499 ASSERT(pluginContainerImpl.get()); |
| 500 | 500 |
| 501 IntRect windowRect, clipRect, unobscuredRect; | 501 IntRect windowRect, clipRect, unobscuredRect; |
| 502 Vector<IntRect> cutOutRects; | 502 Vector<IntRect> cutOutRects; |
| 503 | 503 |
| 504 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); | 504 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); |
| 505 // TODO(chrishtr): these values should not be -1, they should be 0. They are
-1 because WebPluginContainerImpl currently uses an IntRect for | 505 // TODO(chrishtr): these values should not be -1, they should be 0. They are
-1 because WebPluginContainerImpl currently uses an IntRect for |
| 506 // frameRect() to determine the position of the plugin, which results in a l
oss of precision if it is actually subpixel positioned. | 506 // frameRect() to determine the position of the plugin, which results in a l
oss of precision if it is actually subpixel positioned. |
| 507 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), windowRect); | 507 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), windowRect); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 538 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 538 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 539 CustomPluginWebFrameClient<TopmostPlugin> pluginWebFrameClient; // Must outl
ive webViewHelper. | 539 CustomPluginWebFrameClient<TopmostPlugin> pluginWebFrameClient; // Must outl
ive webViewHelper. |
| 540 FrameTestHelpers::WebViewHelper webViewHelper; | 540 FrameTestHelpers::WebViewHelper webViewHelper; |
| 541 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 541 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 542 ASSERT(webView); | 542 ASSERT(webView); |
| 543 webView->settings()->setPluginsEnabled(true); | 543 webView->settings()->setPluginsEnabled(true); |
| 544 webView->resize(WebSize(300, 300)); | 544 webView->resize(WebSize(300, 300)); |
| 545 webView->updateAllLifecyclePhases(); | 545 webView->updateAllLifecyclePhases(); |
| 546 runPendingTasks(); | 546 runPendingTasks(); |
| 547 | 547 |
| 548 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = | 548 RawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 549 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 549 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 550 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 550 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 551 | 551 |
| 552 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); | 552 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| 553 | 553 |
| 554 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); | 554 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); |
| 555 EXPECT_TRUE(testPlugin->isRectTopmost()); | 555 EXPECT_TRUE(testPlugin->isRectTopmost()); |
| 556 | 556 |
| 557 // Cause the plugin's frame to be detached. | 557 // Cause the plugin's frame to be detached. |
| 558 webViewHelper.reset(); | 558 webViewHelper.reset(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 FrameTestHelpers::WebViewHelper webViewHelper; | 610 FrameTestHelpers::WebViewHelper webViewHelper; |
| 611 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin.html"
, true, &webFrameClient); | 611 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin.html"
, true, &webFrameClient); |
| 612 ASSERT_TRUE(webView); | 612 ASSERT_TRUE(webView); |
| 613 webView->settings()->setPluginsEnabled(true); | 613 webView->settings()->setPluginsEnabled(true); |
| 614 webView->resize(WebSize(800, 600)); | 614 webView->resize(WebSize(800, 600)); |
| 615 webView->updateAllLifecyclePhases(); | 615 webView->updateAllLifecyclePhases(); |
| 616 runPendingTasks(); | 616 runPendingTasks(); |
| 617 | 617 |
| 618 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(get
WebPluginContainer(webView, WebString::fromUTF8("plugin"))); | 618 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(get
WebPluginContainer(webView, WebString::fromUTF8("plugin"))); |
| 619 ASSERT_TRUE(container); | 619 ASSERT_TRUE(container); |
| 620 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele
ment>>(container->element()); | 620 RawPtr<Element> element = static_cast<RawPtr<Element>>(container->element())
; |
| 621 const auto* plugin = static_cast<const CompositedPlugin*>(container->plugin(
)); | 621 const auto* plugin = static_cast<const CompositedPlugin*>(container->plugin(
)); |
| 622 | 622 |
| 623 OwnPtr<PaintController> paintController = PaintController::create(); | 623 OwnPtr<PaintController> paintController = PaintController::create(); |
| 624 GraphicsContext graphicsContext(*paintController); | 624 GraphicsContext graphicsContext(*paintController); |
| 625 container->paint(graphicsContext, CullRect(IntRect(10, 10, 400, 300))); | 625 container->paint(graphicsContext, CullRect(IntRect(10, 10, 400, 300))); |
| 626 paintController->commitNewDisplayItems(); | 626 paintController->commitNewDisplayItems(); |
| 627 | 627 |
| 628 const auto& displayItems = paintController->paintArtifact().getDisplayItemLi
st(); | 628 const auto& displayItems = paintController->paintArtifact().getDisplayItemLi
st(); |
| 629 ASSERT_EQ(1u, displayItems.size()); | 629 ASSERT_EQ(1u, displayItems.size()); |
| 630 EXPECT_EQ(element->layoutObject(), &displayItems[0].client()); | 630 EXPECT_EQ(element->layoutObject(), &displayItems[0].client()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 648 runPendingTasks(); | 648 runPendingTasks(); |
| 649 | 649 |
| 650 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 650 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 651 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 651 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 652 | 652 |
| 653 runPendingTasks(); | 653 runPendingTasks(); |
| 654 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); | 654 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); |
| 655 } | 655 } |
| 656 | 656 |
| 657 } // namespace blink | 657 } // namespace blink |
| OLD | NEW |