diff options
Diffstat (limited to 'Source/WebKit/chromium/src/WebPluginContainerImpl.cpp')
-rw-r--r-- | Source/WebKit/chromium/src/WebPluginContainerImpl.cpp | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp index 5c164319e..689154058 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp @@ -33,6 +33,7 @@ #include "Chrome.h" #include "ChromeClientImpl.h" +#include "ClipboardChromium.h" #include "ScrollbarGroup.h" #include "WebCursorInfo.h" #include "WebDataSourceImpl.h" @@ -73,6 +74,7 @@ #include <public/Platform.h> #include <public/WebClipboard.h> #include <public/WebCompositorSupport.h> +#include <public/WebDragData.h> #include <public/WebExternalTextureLayer.h> #include <public/WebRect.h> #include <public/WebString.h> @@ -115,8 +117,13 @@ void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRec if (!parent()) return; + FloatRect scaledDamageRect = damageRect; + float frameScaleFactor = m_element->document()->page()->mainFrame()->frameScaleFactor(); + scaledDamageRect.scale(frameScaleFactor); + scaledDamageRect.move(-frameRect().x() * (frameScaleFactor - 1), -frameRect().y() * (frameScaleFactor - 1)); + // Don't paint anything if the plugin doesn't intersect the damage rect. - if (!frameRect().intersects(damageRect)) + if (!frameRect().intersects(enclosingIntRect(scaledDamageRect))) return; gc->save(); @@ -132,7 +139,7 @@ void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRec WebCanvas* canvas = gc->platformContext()->canvas(); IntRect windowRect = - IntRect(view->contentsToWindow(damageRect.location()), damageRect.size()); + IntRect(view->contentsToWindow(enclosingIntRect(scaledDamageRect))); m_webPlugin->paint(canvas, windowRect); gc->restore(); @@ -653,11 +660,16 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) { ASSERT(parent()->isFrameView()); + if (event->isDragEvent()) { + handleDragEvent(event); + return; + } + // We cache the parent FrameView here as the plugin widget could be deleted // in the call to HandleEvent. See http://b/issue?id=1362948 FrameView* parentView = static_cast<FrameView*>(parent()); - WebMouseEventBuilder webEvent(this, *event); + WebMouseEventBuilder webEvent(this, m_element->renderer(), *event); if (webEvent.type == WebInputEvent::Undefined) return; @@ -696,9 +708,35 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) chromeClient->setCursorForPlugin(cursorInfo); } +void WebPluginContainerImpl::handleDragEvent(MouseEvent* event) +{ + ASSERT(event->isDragEvent()); + + WebDragStatus dragStatus = WebDragStatusUnknown; + if (event->type() == eventNames().dragenterEvent) + dragStatus = WebDragStatusEnter; + else if (event->type() == eventNames().dragleaveEvent) + dragStatus = WebDragStatusLeave; + else if (event->type() == eventNames().dragoverEvent) + dragStatus = WebDragStatusOver; + else if (event->type() == eventNames().dropEvent) + dragStatus = WebDragStatusDrop; + + if (dragStatus == WebDragStatusUnknown) + return; + + ClipboardChromium* clipboard = static_cast<ClipboardChromium*>(event->dataTransfer()); + WebDragData dragData = clipboard->dataObject(); + WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>(clipboard->sourceOperation()); + WebPoint dragScreenLocation(event->screenX(), event->screenY()); + WebPoint dragLocation(event->absoluteLocation().x() - location().x(), event->absoluteLocation().y() - location().y()); + + m_webPlugin->handleDragStatusUpdate(dragStatus, dragData, dragOperationMask, dragLocation, dragScreenLocation); +} + void WebPluginContainerImpl::handleWheelEvent(WheelEvent* event) { - WebMouseWheelEventBuilder webEvent(this, *event); + WebMouseWheelEventBuilder webEvent(this, m_element->renderer(), *event); if (webEvent.type == WebInputEvent::Undefined) return; @@ -747,7 +785,9 @@ void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event) void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) { - WebTouchEventBuilder webEvent(this, *event); + if (!m_isAcceptingTouchEvents) + return; + WebTouchEventBuilder webEvent(this, m_element->renderer(), *event); if (webEvent.type == WebInputEvent::Undefined) return; WebCursorInfo cursorInfo; @@ -758,7 +798,7 @@ void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event) { - WebGestureEventBuilder webEvent(this, *event); + WebGestureEventBuilder webEvent(this, m_element->renderer(), *event); if (webEvent.type == WebInputEvent::Undefined) return; WebCursorInfo cursorInfo; |