| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "public/web/WebPluginContainer.h" | 31 #include "public/web/WebPluginContainer.h" |
| 32 | 32 |
| 33 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
| 34 #include "core/events/KeyboardEvent.h" | 34 #include "core/events/KeyboardEvent.h" |
| 35 #include "core/frame/EventHandlerRegistry.h" | 35 #include "core/frame/EventHandlerRegistry.h" |
| 36 #include "core/frame/FrameHost.h" | 36 #include "core/frame/FrameHost.h" |
| 37 #include "core/layout/LayoutObject.h" | 37 #include "core/layout/LayoutObject.h" |
| 38 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
| 39 #include "platform/PlatformEvent.h" | 39 #include "platform/PlatformEvent.h" |
| 40 #include "platform/PlatformKeyboardEvent.h" | |
| 41 #include "platform/graphics/GraphicsContext.h" | 40 #include "platform/graphics/GraphicsContext.h" |
| 42 #include "platform/graphics/paint/CullRect.h" | 41 #include "platform/graphics/paint/CullRect.h" |
| 43 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 42 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
| 44 #include "platform/graphics/paint/PaintController.h" | 43 #include "platform/graphics/paint/PaintController.h" |
| 45 #include "platform/testing/URLTestHelpers.h" | 44 #include "platform/testing/URLTestHelpers.h" |
| 46 #include "platform/testing/UnitTestHelpers.h" | 45 #include "platform/testing/UnitTestHelpers.h" |
| 47 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
| 48 #include "public/platform/WebClipboard.h" | 47 #include "public/platform/WebClipboard.h" |
| 49 #include "public/platform/WebCompositorSupport.h" | 48 #include "public/platform/WebCompositorSupport.h" |
| 50 #include "public/platform/WebLayer.h" | 49 #include "public/platform/WebLayer.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 362 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 364 FrameTestHelpers::WebViewHelper webViewHelper; | 363 FrameTestHelpers::WebViewHelper webViewHelper; |
| 365 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 364 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 366 DCHECK(webView); | 365 DCHECK(webView); |
| 367 webView->settings()->setPluginsEnabled(true); | 366 webView->settings()->setPluginsEnabled(true); |
| 368 webView->resize(WebSize(300, 300)); | 367 webView->resize(WebSize(300, 300)); |
| 369 webView->updateAllLifecyclePhases(); | 368 webView->updateAllLifecyclePhases(); |
| 370 runPendingTasks(); | 369 runPendingTasks(); |
| 371 | 370 |
| 372 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 371 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 373 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 372 WebInputEvent::Modifiers modifierKey = static_cast<WebInputEvent::Modifiers>
(WebInputEvent::ControlKey | WebInputEvent::NumLockOn | WebInputEvent::IsLeft); |
| 374 #if OS(MACOSX) | 373 #if OS(MACOSX) |
| 375 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 374 modifierKey = static_cast<WebInputEvent::Modifiers>(WebInputEvent::MetaKey |
WebInputEvent::NumLockOn | WebInputEvent::IsLeft); |
| 376 #endif | 375 #endif |
| 377 PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "",
"", "", "", 67, 0, false, modifierKey, 0.0); | 376 WebKeyboardEvent webKeyboardEventC; |
| 378 KeyboardEvent* keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0); | 377 webKeyboardEventC.type = WebInputEvent::RawKeyDown; |
| 378 webKeyboardEventC.modifiers = modifierKey; |
| 379 webKeyboardEventC.windowsKeyCode = 67; |
| 380 KeyboardEvent* keyEventC = KeyboardEvent::create(webKeyboardEventC, 0); |
| 379 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventC); | 381 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventC); |
| 380 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 382 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 381 | 383 |
| 382 // Clearing |Clipboard::Buffer()|. | 384 // Clearing |Clipboard::Buffer()|. |
| 383 Platform::current()->clipboard()->writePlainText(WebString("")); | 385 Platform::current()->clipboard()->writePlainText(WebString("")); |
| 384 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); | 386 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); |
| 385 | 387 |
| 386 PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown,
"", "", "", "", 45, 0, false, modifierKey, 0.0); | 388 WebKeyboardEvent webKeyboardEventInsert; |
| 387 KeyboardEvent* keyEventInsert = KeyboardEvent::create(platformKeyboardEventI
nsert, 0); | 389 webKeyboardEventInsert.type = WebInputEvent::RawKeyDown; |
| 390 webKeyboardEventInsert.modifiers = modifierKey; |
| 391 webKeyboardEventInsert.windowsKeyCode = 45; |
| 392 KeyboardEvent* keyEventInsert = KeyboardEvent::create(webKeyboardEventInsert
, 0); |
| 388 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventInsert); | 393 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventInsert); |
| 389 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 394 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 390 } | 395 } |
| 391 | 396 |
| 392 // A class to facilitate testing that events are correctly received by plugins. | 397 // A class to facilitate testing that events are correctly received by plugins. |
| 393 class EventTestPlugin : public FakeWebPlugin { | 398 class EventTestPlugin : public FakeWebPlugin { |
| 394 public: | 399 public: |
| 395 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) | 400 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) |
| 396 : FakeWebPlugin(frame, params) | 401 : FakeWebPlugin(frame, params) |
| 397 , m_lastEventType(WebInputEvent::Undefined) | 402 , m_lastEventType(WebInputEvent::Undefined) |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 runPendingTasks(); | 688 runPendingTasks(); |
| 684 | 689 |
| 685 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 690 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 686 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 691 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 687 | 692 |
| 688 runPendingTasks(); | 693 runPendingTasks(); |
| 689 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); | 694 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); |
| 690 } | 695 } |
| 691 | 696 |
| 692 } // namespace blink | 697 } // namespace blink |
| OLD | NEW |