summaryrefslogtreecommitdiff
path: root/Source/web/WebPluginContainerImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/web/WebPluginContainerImpl.cpp')
-rw-r--r--Source/web/WebPluginContainerImpl.cpp77
1 files changed, 38 insertions, 39 deletions
diff --git a/Source/web/WebPluginContainerImpl.cpp b/Source/web/WebPluginContainerImpl.cpp
index ab829a5c3..713d2c2f7 100644
--- a/Source/web/WebPluginContainerImpl.cpp
+++ b/Source/web/WebPluginContainerImpl.cpp
@@ -43,40 +43,40 @@
#include "WebViewImpl.h"
#include "core/page/Chrome.h"
#include "core/page/EventHandler.h"
-#include "core/platform/chromium/ClipboardChromium.h"
#include "core/platform/chromium/support/WrappedResourceResponse.h"
#include "HTMLNames.h"
#include "WebPrintParams.h"
#include "bindings/v8/ScriptController.h"
-#include "core/events/EventNames.h"
+#include "core/dom/Clipboard.h"
#include "core/events/GestureEvent.h"
#include "core/events/KeyboardEvent.h"
#include "core/events/MouseEvent.h"
-#include "core/dom/TouchController.h"
+#include "core/events/ThreadLocalEventNames.h"
#include "core/events/TouchEvent.h"
-#include "core/dom/UserGestureIndicator.h"
#include "core/events/WheelEvent.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/HTMLPlugInElement.h"
#include "core/loader/FormState.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/page/FocusController.h"
-#include "core/page/Frame.h"
-#include "core/page/FrameView.h"
+#include "core/frame/Frame.h"
+#include "core/frame/FrameView.h"
#include "core/page/Page.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
-#include "core/platform/HostWindow.h"
-#include "core/platform/PlatformGestureEvent.h"
#include "core/platform/ScrollAnimator.h"
#include "core/platform/ScrollView.h"
#include "core/platform/ScrollbarTheme.h"
+#include "core/platform/chromium/ChromiumDataObject.h"
#include "core/platform/chromium/KeyboardCodes.h"
#include "core/platform/graphics/GraphicsContext.h"
#include "core/platform/graphics/GraphicsLayer.h"
#include "core/plugins/PluginOcclusionSupport.h"
#include "core/rendering/HitTestResult.h"
#include "core/rendering/RenderBox.h"
+#include "platform/HostWindow.h"
+#include "platform/PlatformGestureEvent.h"
+#include "platform/UserGestureIndicator.h"
#include "public/platform/Platform.h"
#include "public/platform/WebClipboard.h"
#include "public/platform/WebCompositorSupport.h"
@@ -124,7 +124,7 @@ void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRec
gc->save();
ASSERT(parent()->isFrameView());
- ScrollView* view = parent();
+ ScrollView* view = toScrollView(parent());
// The plugin is positioned in window coordinates, so it needs to be painted
// in window coordinates.
@@ -189,14 +189,14 @@ void WebPluginContainerImpl::handleEvent(Event* event)
// where mozilla behaves differently than the spec.
if (event->isMouseEvent())
handleMouseEvent(toMouseEvent(event));
- else if (event->hasInterface(eventNames().interfaceForWheelEvent))
- handleWheelEvent(static_cast<WheelEvent*>(event));
+ else if (event->isWheelEvent())
+ handleWheelEvent(toWheelEvent(event));
else if (event->isKeyboardEvent())
handleKeyboardEvent(toKeyboardEvent(event));
- else if (eventNames().isTouchEventType(event->type()))
+ else if (event->isTouchEvent())
handleTouchEvent(toTouchEvent(event));
- else if (eventNames().isGestureEventType(event->type()))
- handleGestureEvent(static_cast<GestureEvent*>(event));
+ else if (event->isGestureEvent())
+ handleGestureEvent(toGestureEvent(event));
// FIXME: it would be cleaner if Widget::handleEvent returned true/false and
// HTMLPluginElement called setDefaultHandled or defaultEventHandler.
@@ -246,15 +246,15 @@ void WebPluginContainerImpl::setParentVisible(bool parentVisible)
m_webPlugin->updateVisibility(isVisible());
}
-void WebPluginContainerImpl::setParent(ScrollView* view)
+void WebPluginContainerImpl::setParent(Widget* widget)
{
// We override this function so that if the plugin is windowed, we can call
// NPP_SetWindow at the first possible moment. This ensures that
// NPP_SetWindow is called before the manual load data is sent to a plugin.
// If this order is reversed, Flash won't load videos.
- Widget::setParent(view);
- if (view)
+ Widget::setParent(widget);
+ if (widget)
reportGeometry();
}
@@ -441,7 +441,8 @@ WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup
String script = decodeURLEscapeSequences(
kurl.string().substring(strlen("javascript:")));
- ScriptValue result = frame->script()->executeScript(script, popupsAllowed);
+ UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNewUserGesture : PossiblyProcessingUserGesture);
+ ScriptValue result = frame->script()->executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script));
// Failure is reported as a null string.
String resultStr;
@@ -500,11 +501,10 @@ void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType request
if (m_touchEventRequestType == requestType)
return;
- Document& document = m_element->document();
if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == TouchEventRequestTypeNone)
- TouchController::from(&document)->didAddTouchEventHandler(&document, m_element);
+ m_element->document().didAddTouchEventHandler(m_element);
else if (requestType == TouchEventRequestTypeNone && m_touchEventRequestType != TouchEventRequestTypeNone)
- TouchController::from(&document)->didRemoveTouchEventHandler(&document, m_element);
+ m_element->document().didRemoveTouchEventHandler(m_element);
m_touchEventRequestType = requestType;
}
@@ -523,7 +523,7 @@ void WebPluginContainerImpl::setWantsWheelEvents(bool wantsWheelEvents)
WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point)
{
- ScrollView* view = parent();
+ ScrollView* view = toScrollView(parent());
if (!view)
return point;
WebPoint windowPoint = view->windowToContents(point);
@@ -532,7 +532,7 @@ WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point)
WebPoint WebPluginContainerImpl::localToWindowPoint(const WebPoint& point)
{
- ScrollView* view = parent();
+ ScrollView* view = toScrollView(parent());
if (!view)
return point;
IntPoint absolutePoint = roundedIntPoint(m_element->renderer()->localToAbsolute(LayoutPoint(point), UseTransforms));
@@ -649,10 +649,8 @@ WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* eleme
WebPluginContainerImpl::~WebPluginContainerImpl()
{
- if (m_touchEventRequestType != TouchEventRequestTypeNone) {
- Document& document = m_element->document();
- TouchController::from(&document)->didRemoveTouchEventHandler(&document, m_element);
- }
+ if (m_touchEventRequestType != TouchEventRequestTypeNone)
+ m_element->document().didRemoveTouchEventHandler(m_element);
for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
m_pluginLoadObservers[i]->clearPluginContainer();
@@ -679,18 +677,18 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
if (webEvent.type == WebInputEvent::Undefined)
return;
- if (event->type() == eventNames().mousedownEvent)
+ if (event->type() == EventTypeNames::mousedown)
focusPlugin();
if (m_scrollbarGroup) {
// This needs to be set before the other callbacks in this scope, since
// the scroll animator class might query the position in response.
m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y()));
- if (event->type() == eventNames().mousemoveEvent)
+ if (event->type() == EventTypeNames::mousemove)
m_scrollbarGroup->scrollAnimator()->mouseMovedInContentArea();
- else if (event->type() == eventNames().mouseoverEvent)
+ else if (event->type() == EventTypeNames::mouseover)
m_scrollbarGroup->scrollAnimator()->mouseEnteredContentArea();
- else if (event->type() == eventNames().mouseoutEvent)
+ else if (event->type() == EventTypeNames::mouseout)
m_scrollbarGroup->scrollAnimator()->mouseExitedContentArea();
}
@@ -704,7 +702,7 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
Page* page = parentView->frame().page();
if (!page)
return;
- ChromeClientImpl* chromeClient = static_cast<ChromeClientImpl*>(&page->chrome().client());
+ ChromeClientImpl* chromeClient = toChromeClientImpl(page->chrome().client());
chromeClient->setCursorForPlugin(cursorInfo);
}
@@ -713,19 +711,19 @@ void WebPluginContainerImpl::handleDragEvent(MouseEvent* event)
ASSERT(event->isDragEvent());
WebDragStatus dragStatus = WebDragStatusUnknown;
- if (event->type() == eventNames().dragenterEvent)
+ if (event->type() == EventTypeNames::dragenter)
dragStatus = WebDragStatusEnter;
- else if (event->type() == eventNames().dragleaveEvent)
+ else if (event->type() == EventTypeNames::dragleave)
dragStatus = WebDragStatusLeave;
- else if (event->type() == eventNames().dragoverEvent)
+ else if (event->type() == EventTypeNames::dragover)
dragStatus = WebDragStatusOver;
- else if (event->type() == eventNames().dropEvent)
+ else if (event->type() == EventTypeNames::drop)
dragStatus = WebDragStatusDrop;
if (dragStatus == WebDragStatusUnknown)
return;
- ClipboardChromium* clipboard = static_cast<ClipboardChromium*>(event->dataTransfer());
+ Clipboard* clipboard = event->dataTransfer();
WebDragData dragData = clipboard->dataObject();
WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation());
WebPoint dragScreenLocation(event->screenX(), event->screenY());
@@ -798,7 +796,7 @@ void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event)
if (webEvent.type == WebInputEvent::Undefined)
return;
- if (event->type() == eventNames().touchstartEvent)
+ if (event->type() == EventTypeNames::touchstart)
focusPlugin();
WebCursorInfo cursorInfo;
@@ -868,7 +866,7 @@ void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect,
IntRect& clipRect,
Vector<IntRect>& cutOutRects)
{
- windowRect = parent()->contentsToWindow(frameRect);
+ windowRect = toScrollView(parent())->contentsToWindow(frameRect);
// Calculate a clip-rect so that we don't overlap the scrollbars, etc.
clipRect = windowClipRect();
@@ -888,6 +886,7 @@ WebCore::IntRect WebPluginContainerImpl::windowClipRect() const
// document().renderer() can be 0 when we receive messages from the
// plugins while we are destroying a frame.
+ // FIXME: Can we just check m_element->document().isActive() ?
if (m_element->renderer()->document().renderer()) {
// Take our element and get the clip rect from the enclosing layer and
// frame view.