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