summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-06-03 13:12:31 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-06 13:02:41 +0200
commit57626c5f3624b3b55d3b5a49118bca8a5baad8b3 (patch)
tree3fc1d1739ca29f5f6e6653cd8c587ce6a9ccccc1
parent50ccde81258f6d9f9147b8b1c52adb90db22cd3e (diff)
downloadqtwebkit-57626c5f3624b3b55d3b5a49118bca8a5baad8b3.tar.gz
[Qt][Mac] Remove Carbon and QuickDraw support for plugins.
https://bugs.webkit.org/show_bug.cgi?id=116619 Reviewed by Tor Arne Vestbø. They are only enabled for 32bit builds of QtWebKit and are rarely tested. Other browsers support them through a 32bit host process. PluginViewMac.mm is only used by Qt since the Wx port was removed. - Only support the Cocoa event model - Only support the CoreGraphics drawing model - Remove all NP_NO_CARBON and NP_NO_QUICKDRAW blocks in PluginViewMac.mm * plugins/PluginView.cpp: (WebCore::PluginView::setValue): (WebCore::PluginView::PluginView): * plugins/PluginView.h: * plugins/mac/PluginViewMac.mm: (WebCore::PluginView::platformStart): (WebCore::PluginView::platformDestroy): (WebCore::PluginView::platformGetValueStatic): (WebCore::PluginView::setFocus): (WebCore::PluginView::setNPWindowIfNeeded): (WebCore::PluginView::paint): (WebCore::PluginView::handleWheelEvent): (WebCore::PluginView::handleMouseEvent): (WebCore::PluginView::handleKeyboardEvent): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151106 268f45cc-cd09-0410-ab3c-d52691b4dbfc Conflicts: Source/WebCore/plugins/mac/PluginViewMac.mm Change-Id: Id4939dfe00a306299ab54c28b03f949ce4beb4d8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
-rw-r--r--Source/WebCore/plugins/PluginView.cpp12
-rw-r--r--Source/WebCore/plugins/PluginView.h10
-rw-r--r--Source/WebCore/plugins/mac/PluginViewMac.mm647
3 files changed, 154 insertions, 515 deletions
diff --git a/Source/WebCore/plugins/PluginView.cpp b/Source/WebCore/plugins/PluginView.cpp
index 8a31103af..861372f9d 100644
--- a/Source/WebCore/plugins/PluginView.cpp
+++ b/Source/WebCore/plugins/PluginView.cpp
@@ -646,11 +646,7 @@ NPError PluginView::setValue(NPPVariable variable, void* value)
NPDrawingModel newDrawingModel = NPDrawingModel(uintptr_t(value));
switch (newDrawingModel) {
case NPDrawingModelCoreGraphics:
- m_drawingModel = newDrawingModel;
return NPERR_NO_ERROR;
-#ifndef NP_NO_QUICKDRAW
- case NPDrawingModelQuickDraw:
-#endif
case NPDrawingModelCoreAnimation:
default:
LOG(Plugins, "Plugin asked for unsupported drawing model: %s",
@@ -666,13 +662,8 @@ NPError PluginView::setValue(NPPVariable variable, void* value)
NPEventModel newEventModel = NPEventModel(uintptr_t(value));
switch (newEventModel) {
-#ifndef NP_NO_CARBON
- case NPEventModelCarbon:
-#endif
case NPEventModelCocoa:
- m_eventModel = newEventModel;
return NPERR_NO_ERROR;
-
default:
LOG(Plugins, "Plugin asked for unsupported event model: %s",
prettyNameForEventModel(newEventModel));
@@ -860,10 +851,7 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p
, m_window(0)
#endif
#if defined(XP_MACOSX)
- , m_drawingModel(NPDrawingModel(-1))
- , m_eventModel(NPEventModel(-1))
, m_contextRef(0)
- , m_fakeWindow(0)
#endif
#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
, m_hasPendingGeometryChange(true)
diff --git a/Source/WebCore/plugins/PluginView.h b/Source/WebCore/plugins/PluginView.h
index 84e62d8ae..821c16161 100644
--- a/Source/WebCore/plugins/PluginView.h
+++ b/Source/WebCore/plugins/PluginView.h
@@ -323,10 +323,8 @@ namespace WebCore {
void lifeSupportTimerFired(Timer<PluginView>*);
Timer<PluginView> m_lifeSupportTimer;
-#ifndef NP_NO_CARBON
#if ENABLE(NETSCAPE_PLUGIN_API)
bool dispatchNPEvent(NPEvent&);
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
#endif
#if defined(XP_MACOSX) && ENABLE(NETSCAPE_PLUGIN_API)
int16_t dispatchNPCocoaEvent(NPCocoaEvent&);
@@ -411,20 +409,12 @@ private:
void setNPWindowIfNeeded();
#elif defined(XP_MACOSX)
NP_CGContext m_npCgContext;
- OwnPtr<Timer<PluginView> > m_nullEventTimer;
- NPDrawingModel m_drawingModel;
- NPEventModel m_eventModel;
CGContextRef m_contextRef;
- WindowRef m_fakeWindow;
#if PLATFORM(QT)
QPixmap m_pixmap;
#endif
- Point m_lastMousePos;
void setNPWindowIfNeeded();
- void nullEventTimerFired(Timer<PluginView>*);
- Point globalMousePosForPlugin() const;
- Point mousePosForPlugin(MouseEvent* event = 0) const;
#endif
#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/Source/WebCore/plugins/mac/PluginViewMac.mm b/Source/WebCore/plugins/mac/PluginViewMac.mm
index 849a57fdf..e70d5eee6 100644
--- a/Source/WebCore/plugins/mac/PluginViewMac.mm
+++ b/Source/WebCore/plugins/mac/PluginViewMac.mm
@@ -90,18 +90,12 @@ QT_END_NAMESPACE
#include <wx/wx.h>
#endif
-using std::min;
-
using namespace WTF;
namespace WebCore {
using namespace HTMLNames;
-#ifndef NP_NO_CARBON
-static int modifiersForEvent(UIEventWithKeyState *event);
-#endif
-
static inline WindowRef nativeWindowFor(PlatformWidget widget)
{
#if PLATFORM(QT)
@@ -174,66 +168,16 @@ bool PluginView::platformStart()
ASSERT(m_isStarted);
ASSERT(m_status == PluginStatusLoadedSuccessfully);
- if (m_drawingModel == NPDrawingModel(-1)) {
- // We default to QuickDraw, even though we don't support it,
- // since that's what Safari does, and some plugins expect this
- // behavior and never set the drawing model explicitly.
-#ifndef NP_NO_QUICKDRAW
- m_drawingModel = NPDrawingModelQuickDraw;
-#else
- // QuickDraw not available, so we have to default to CoreGraphics
- m_drawingModel = NPDrawingModelCoreGraphics;
-#endif
- }
-
- if (m_eventModel == NPEventModel(-1)) {
- // If the plug-in did not specify an event model
- // we default to Carbon, when it is available.
-#ifndef NP_NO_CARBON
- m_eventModel = NPEventModelCarbon;
-#else
- m_eventModel = NPEventModelCocoa;
-#endif
- }
-
// Gracefully handle unsupported drawing or event models. We can do this
// now since the drawing and event model can only be set during NPP_New.
-#ifndef NP_NO_CARBON
NPBool eventModelSupported;
- if (getValueStatic(NPNVariable(NPNVsupportsCarbonBool + m_eventModel), &eventModelSupported) != NPERR_NO_ERROR
+ if (getValueStatic(NPNVariable(NPNVsupportsCocoaBool), &eventModelSupported) != NPERR_NO_ERROR
|| !eventModelSupported) {
-#else
- NPBool eventModelSupported;
- if (getValueStatic(NPNVariable(NPNVsupportsCocoaBool/* + m_eventModel*/), &eventModelSupported) != NPERR_NO_ERROR
- || !eventModelSupported) {
-#endif
m_status = PluginStatusCanNotLoadPlugin;
LOG(Plugins, "Plug-in '%s' uses unsupported event model %s",
- m_plugin->name().utf8().data(), prettyNameForEventModel(m_eventModel));
- return false;
- }
-
-#ifndef NP_NO_QUICKDRAW
- NPBool drawingModelSupported;
- if (getValueStatic(NPNVariable(NPNVsupportsQuickDrawBool + m_drawingModel), &drawingModelSupported) != NPERR_NO_ERROR
- || !drawingModelSupported) {
- m_status = PluginStatusCanNotLoadPlugin;
- LOG(Plugins, "Plug-in '%s' uses unsupported drawing model %s",
- m_plugin->name().utf8().data(), prettyNameForDrawingModel(m_drawingModel));
- return false;
- }
-#endif
-
-#ifdef NP_NO_QUICKDRAW
- NPBool drawingModelSupported;
- if (getValueStatic(NPNVariable(NPNVsupportsCoreGraphicsBool/* + m_drawingModel*/), &drawingModelSupported) != NPERR_NO_ERROR
- || !drawingModelSupported) {
- m_status = PluginStatusCanNotLoadPlugin;
- LOG(Plugins, "Plug-in '%s' uses unsupported drawing model %s",
- m_plugin->name().utf8().data(), prettyNameForDrawingModel(m_drawingModel));
+ m_plugin->name().utf8().data(), prettyNameForEventModel(NPEventModelCocoa));
return false;
}
-#endif
#if PLATFORM(QT)
@@ -249,31 +193,11 @@ bool PluginView::platformStart()
setPlatformPluginWidget(widget);
#endif
- // Create a fake window relative to which all events will be sent when using offscreen rendering
-#ifndef NP_NO_CARBON
- if (!platformPluginWidget()) {
- // Make the default size really big. It is unclear why this is required but with a smaller size, mouse move
- // events don't get processed. Resizing the fake window to flash's size doesn't help.
- ::Rect windowBounds = { 0, 0, 1000, 1000 };
- CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes, &windowBounds, &m_fakeWindow);
- // Flash requires the window to be hilited to process mouse move events.
- HiliteWindow(m_fakeWindow, true);
- }
-#endif
-
updatePluginWidget();
if (!m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))
setNPWindowIfNeeded();
-#ifndef NP_NO_CARBON
- // TODO: Implement null timer throttling depending on plugin activation
- m_nullEventTimer = adoptPtr(new Timer<PluginView>(this, &PluginView::nullEventTimerFired));
- m_nullEventTimer->startRepeating(0.02);
-
- m_lastMousePos.h = m_lastMousePos.v = 0;
-#endif // NP_NO_CARBON
-
return true;
}
@@ -283,10 +207,6 @@ void PluginView::platformDestroy()
setPlatformPluginWidget(0);
else {
CGContextRelease(m_contextRef);
-#ifndef NP_NO_CARBON
- if (m_fakeWindow)
- DisposeWindow(m_fakeWindow);
-#endif
}
}
@@ -305,13 +225,6 @@ bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPErr
*result = NPERR_NO_ERROR;
return true;
-#ifndef NP_NO_CARBON
- case NPNVsupportsCarbonBool:
- *static_cast<NPBool*>(value) = true;
- *result = NPERR_NO_ERROR;
- return true;
-
-#endif
case NPNVsupportsCocoaBool:
*static_cast<NPBool*>(value) = true;
*result = NPERR_NO_ERROR;
@@ -328,10 +241,6 @@ bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPErr
*result = NPERR_NO_ERROR;
return true;
-#ifndef NP_NO_QUICKDRAW
- // QuickDraw is deprecated in 10.5 and not supported on 64-bit
- case NPNVsupportsQuickDrawBool:
-#endif
case NPNVsupportsOpenGLBool:
case NPNVsupportsCoreAnimationBool:
*static_cast<NPBool*>(value) = false;
@@ -396,11 +305,8 @@ void PluginView::hide()
void PluginView::setFocus(bool focused)
{
LOG(Plugins, "PluginView::setFocus(%d)", focused);
- if (!focused) {
+ if (!focused)
Widget::setFocus(focused);
- if (m_eventModel != NPEventModelCocoa)
- return;
- }
if (platformPluginWidget())
#if PLATFORM(QT)
@@ -412,28 +318,14 @@ void PluginView::setFocus(bool focused)
Widget::setFocus(focused);
-#ifndef NP_NO_CARBON
- // TODO: Also handle and pass on blur events (focus lost)
- EventRecord record;
- record.what = NPEventType_GetFocusEvent;
- record.message = 0;
- record.when = TickCount();
- record.where = globalMousePosForPlugin();
- record.modifiers = GetCurrentKeyModifiers();
+ NPCocoaEvent cocoaEvent;
+ initializeNPCocoaEvent(&cocoaEvent);
+ cocoaEvent.type = NPCocoaEventFocusChanged;
+ NPBool focus = focused;
+ cocoaEvent.data.focus.hasFocus = focus;
- if (!dispatchNPEvent(record))
- LOG(Events, "PluginView::setFocus(%d): Focus event not accepted", focused);
-#endif
- {
- NPCocoaEvent cocoaEvent;
- initializeNPCocoaEvent(&cocoaEvent);
- cocoaEvent.type = NPCocoaEventFocusChanged;
- NPBool focus = focused;
- cocoaEvent.data.focus.hasFocus = focus;
-
- if(!dispatchNPCocoaEvent(cocoaEvent)) {
- LOG(Events, "PluginView::setFocus(): Focus event %d not accepted", cocoaEvent.type);
- }
+ if(!dispatchNPCocoaEvent(cocoaEvent)) {
+ LOG(Events, "PluginView::setFocus(): Focus event %d not accepted", cocoaEvent.type);
}
}
@@ -456,26 +348,20 @@ void PluginView::setNPWindowIfNeeded()
return;
CGContextRef newContextRef = 0;
- WindowRef newWindowRef = 0;
if (platformPluginWidget()) {
newContextRef = cgHandleFor(platformPluginWidget());
- newWindowRef = nativeWindowFor(platformPluginWidget());
m_npWindow.type = NPWindowTypeWindow;
} else {
newContextRef = m_contextRef;
- newWindowRef = m_fakeWindow;
m_npWindow.type = NPWindowTypeDrawable;
}
- if (!newContextRef || !newWindowRef) {
+ if (!newContextRef) {
if (!m_usePixmap)
return;
}
m_npWindow.window = (void*)&m_npCgContext;
-#ifndef NP_NO_CARBON
- m_npCgContext.window = newWindowRef;
-#endif
m_npCgContext.context = newContextRef;
m_npWindow.x = m_windowRect.x();
@@ -489,9 +375,9 @@ void PluginView::setNPWindowIfNeeded()
m_npWindow.clipRect.right = m_windowRect.x() + m_windowRect.width();
m_npWindow.clipRect.bottom = m_windowRect.y() + m_windowRect.height();
- LOG(Plugins, "PluginView::setNPWindowIfNeeded(): window=%p, context=%p,"
+ LOG(Plugins, "PluginView::setNPWindowIfNeeded(): context=%p,"
" window.x:%d window.y:%d window.width:%d window.height:%d window.clipRect size:%dx%d",
- newWindowRef, newContextRef, m_npWindow.x, m_npWindow.y, m_npWindow.width, m_npWindow.height,
+ newContextRef, m_npWindow.x, m_npWindow.y, m_npWindow.width, m_npWindow.height,
m_npWindow.clipRect.right - m_npWindow.clipRect.left, m_npWindow.clipRect.bottom - m_npWindow.clipRect.top);
PluginView::setCurrentPluginView(this);
@@ -596,33 +482,17 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
#endif
}
-#ifndef NP_NO_CARBON
- if (m_eventModel != NPEventModelCocoa) {
- EventRecord event;
- event.what = updateEvt;
- event.message = (long unsigned int)m_npCgContext.window;
- event.when = TickCount();
- event.where.h = 0;
- event.where.v = 0;
- event.modifiers = GetCurrentKeyModifiers();
-
- if (!dispatchNPEvent(event))
- LOG(Events, "PluginView::paint(): Paint event not accepted");
- } else
-#endif
- {
- NPCocoaEvent cocoaEvent;
- initializeNPCocoaEvent(&cocoaEvent);
- cocoaEvent.type = NPCocoaEventDrawRect;
- cocoaEvent.data.draw.x = m_usePixmap ? 0 : r.origin.x;
- cocoaEvent.data.draw.y = m_usePixmap ? 0 : r.origin.y;
- cocoaEvent.data.draw.width = m_usePixmap ? m_pixmap.width() : r.size.width;
- cocoaEvent.data.draw.height = m_usePixmap ? m_pixmap.height() : r.size.height;
- cocoaEvent.data.draw.context = cgContext;
-
- if(!dispatchNPCocoaEvent(cocoaEvent))
- LOG(Events, "PluginView::paint(): Paint event type %d not accepted", cocoaEvent.type);
- }
+ NPCocoaEvent cocoaEvent;
+ initializeNPCocoaEvent(&cocoaEvent);
+ cocoaEvent.type = NPCocoaEventDrawRect;
+ cocoaEvent.data.draw.x = m_usePixmap ? 0 : r.origin.x;
+ cocoaEvent.data.draw.y = m_usePixmap ? 0 : r.origin.y;
+ cocoaEvent.data.draw.width = m_usePixmap ? m_pixmap.width() : r.size.width;
+ cocoaEvent.data.draw.height = m_usePixmap ? m_pixmap.height() : r.size.height;
+ cocoaEvent.data.draw.context = cgContext;
+
+ if(!dispatchNPCocoaEvent(cocoaEvent))
+ LOG(Events, "PluginView::paint(): Paint event type %d not accepted", cocoaEvent.type);
if (!platformPluginWidget() || m_isTransparent) {
#if PLATFORM(QT)
@@ -684,7 +554,7 @@ void PluginView::forceRedraw()
// ----------------- Event handling --------------------
void PluginView::handleWheelEvent(WheelEvent *event)
{
- if (!m_isStarted || m_eventModel != NPEventModelCocoa)
+ if (!m_isStarted)
return;
NPCocoaEvent cocoaEvent;
@@ -702,8 +572,8 @@ void PluginView::handleWheelEvent(WheelEvent *event)
cocoaEvent.data.mouse.modifierFlags = getModifiers(event);
if(!dispatchNPCocoaEvent(cocoaEvent)) {
- LOG(Events, "PluginView::handleMouseEvent(): Wheel event type %d at %d,%d not accepted", cocoaEvent.type
- cocoaEvent.data.mouse.x, cocoaEvent.data.mouse.y);
+ LOG(Events, "PluginView::handleMouseEvent(): Wheel event type %d at %d,%d not accepted", cocoaEvent.type,
+ cocoaEvent.data.mouse.pluginX, cocoaEvent.data.mouse.pluginY);
}
event->setDefaultHandled();
}
@@ -713,125 +583,80 @@ void PluginView::handleMouseEvent(MouseEvent* event)
if (!m_isStarted)
return;
-#ifndef NP_NO_CARBON
- if (m_eventModel != NPEventModelCocoa) {
- EventRecord record;
-
- if (event->type() == eventNames().mousemoveEvent) {
- // Mouse movement is handled by null timer events
- m_lastMousePos = mousePosForPlugin(event);
- return;
- } else if (event->type() == eventNames().mouseoverEvent) {
- record.what = NPEventType_AdjustCursorEvent;
- } else if (event->type() == eventNames().mouseoutEvent) {
- record.what = NPEventType_AdjustCursorEvent;
- } else if (event->type() == eventNames().mousedownEvent) {
- record.what = mouseDown;
+ NPCocoaEventType eventType;
+ int32_t buttonNumber = 0;
+ int32_t clickCount = 0;
+ NSEvent *currentEvent = [NSApp currentEvent];
+
+ NSEventType type = [currentEvent type];
+
+ switch (type) {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
+ buttonNumber = [currentEvent buttonNumber];
+ clickCount = [currentEvent clickCount];
+ eventType = NPCocoaEventMouseDown;
// The plugin needs focus to receive keyboard events
if (Page* page = m_parentFrame->page())
page->focusController()->setFocusedFrame(m_parentFrame);
m_parentFrame->document()->setFocusedNode(m_element);
- } else if (event->type() == eventNames().mouseupEvent) {
- record.what = mouseUp;
- } else {
+ break;
+
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ buttonNumber = [currentEvent buttonNumber];
+ clickCount = [currentEvent clickCount];
+ eventType = NPCocoaEventMouseUp;
+ break;
+
+ case NSMouseMoved:
+ eventType = NPCocoaEventMouseMoved;
+ break;
+
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ buttonNumber = [currentEvent buttonNumber];
+ eventType = NPCocoaEventMouseDragged;
+ break;
+
+ case NSMouseEntered:
+ eventType = NPCocoaEventMouseEntered;
+ break;
+
+ case NSMouseExited:
+ eventType = NPCocoaEventMouseExited;
+ default:
return;
- }
- record.where = mousePosForPlugin(event);
- record.modifiers = modifiersForEvent(event);
-
- if (!event->buttonDown())
- record.modifiers |= btnState;
-
- if (event->button() == 2)
- record.modifiers |= controlKey;
-
- if (!dispatchNPEvent(record)) {
- if (record.what == NPEventType_AdjustCursorEvent)
- return; // Signals that the plugin wants a normal cursor
-
- LOG(Events, "PluginView::handleMouseEvent(): Mouse event type %d at %d,%d not accepted",
- record.what, record.where.h, record.where.v);
- } else {
- event->setDefaultHandled();
- }
- } else
-#endif
- {
- NPCocoaEventType eventType;
- int32_t buttonNumber = 0;
- int32_t clickCount = 0;
- NSEvent *currentEvent = [NSApp currentEvent];
-
- NSEventType type = [currentEvent type];
-
- switch (type) {
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
- buttonNumber = [currentEvent buttonNumber];
- clickCount = [currentEvent clickCount];
- eventType = NPCocoaEventMouseDown;
- // The plugin needs focus to receive keyboard events
- if (Page* page = m_parentFrame->page())
- page->focusController()->setFocusedFrame(m_parentFrame);
- m_parentFrame->document()->setFocusedNode(m_element);
- break;
-
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
- buttonNumber = [currentEvent buttonNumber];
- clickCount = [currentEvent clickCount];
- eventType = NPCocoaEventMouseUp;
- break;
-
- case NSMouseMoved:
- eventType = NPCocoaEventMouseMoved;
- break;
-
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- buttonNumber = [currentEvent buttonNumber];
- eventType = NPCocoaEventMouseDragged;
- break;
-
- case NSMouseEntered:
- eventType = NPCocoaEventMouseEntered;
- break;
-
- case NSMouseExited:
- eventType = NPCocoaEventMouseExited;
- default:
- return;
- }
-
- NPCocoaEvent cocoaEvent;
- initializeNPCocoaEvent(&cocoaEvent);
-
- cocoaEvent.type = eventType;
- if (!(NPCocoaEventMouseEntered == eventType || NPCocoaEventMouseExited == eventType)) {
- cocoaEvent.data.mouse.buttonNumber = buttonNumber;
- cocoaEvent.data.mouse.clickCount = clickCount;
- }
-
- cocoaEvent.data.mouse.pluginX = event->layerX() - m_npWindow.x + m_windowRect.x() - m_element->offsetLeft();
- cocoaEvent.data.mouse.pluginY = event->layerY() - m_npWindow.y + m_windowRect.y() - m_element->offsetTop();
- cocoaEvent.data.mouse.deltaX = [currentEvent deltaX];
- cocoaEvent.data.mouse.deltaY = [currentEvent deltaY];
- cocoaEvent.data.mouse.deltaZ = [currentEvent deltaZ];
- cocoaEvent.data.mouse.modifierFlags = getModifiers(event);
-
- int16_t response = dispatchNPCocoaEvent(cocoaEvent);
- if(response = kNPEventNotHandled) {
- LOG(Events, "PluginView::handleMouseEvent(): Mouse event type %d at %d,%d not accepted", cocoaEvent.type
- cocoaEvent.data.mouse.x, cocoaEvent.data.mouse.y);
- }
-
- // Safari policy is to return true for all mouse events, because some plugins
- // return false even if they have handled the event.
- event->setDefaultHandled();
}
+
+ NPCocoaEvent cocoaEvent;
+ initializeNPCocoaEvent(&cocoaEvent);
+
+ cocoaEvent.type = eventType;
+ if (!(NPCocoaEventMouseEntered == eventType || NPCocoaEventMouseExited == eventType)) {
+ cocoaEvent.data.mouse.buttonNumber = buttonNumber;
+ cocoaEvent.data.mouse.clickCount = clickCount;
+ }
+
+ cocoaEvent.data.mouse.pluginX = event->layerX() - m_npWindow.x + m_windowRect.x() - m_element->offsetLeft();
+ cocoaEvent.data.mouse.pluginY = event->layerY() - m_npWindow.y + m_windowRect.y() - m_element->offsetTop();
+ cocoaEvent.data.mouse.deltaX = [currentEvent deltaX];
+ cocoaEvent.data.mouse.deltaY = [currentEvent deltaY];
+ cocoaEvent.data.mouse.deltaZ = [currentEvent deltaZ];
+ cocoaEvent.data.mouse.modifierFlags = getModifiers(event);
+
+ int16_t response = dispatchNPCocoaEvent(cocoaEvent);
+ if(response == kNPEventNotHandled) {
+ LOG(Events, "PluginView::handleMouseEvent(): Mouse event type %d at %d,%d not accepted", cocoaEvent.type,
+ cocoaEvent.data.mouse.pluginX, cocoaEvent.data.mouse.pluginY);
+ }
+
+ // Safari policy is to return true for all mouse events, because some plugins
+ // return false even if they have handled the event.
+ event->setDefaultHandled();
}
void PluginView::handleKeyboardEvent(KeyboardEvent* event)
@@ -839,238 +664,74 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
if (!m_isStarted)
return;
LOG(Plugins, "PluginView::handleKeyboardEvent() ----------------- ");
-
+
LOG(Plugins, "PV::hKE(): KE.keyCode: 0x%02X, KE.charCode: %d",
event->keyCode(), event->charCode());
-
-#ifndef NP_NO_CARBON
- if (m_eventModel != NPEventModelCocoa) {
- EventRecord record;
- if (event->type() == eventNames().keydownEvent) {
- // This event is the result of a PlatformKeyboardEvent::KeyDown which
- // was disambiguated into a PlatformKeyboardEvent::RawKeyDown. Since
- // we don't have access to the text here, we return, and wait for the
- // corresponding event based on PlatformKeyboardEvent::Char.
- return;
- } else if (event->type() == eventNames().keypressEvent) {
- // Which would be this one. This event was disambiguated from the same
- // PlatformKeyboardEvent::KeyDown, but to a PlatformKeyboardEvent::Char,
- // which retains the text from the original event. So, we can safely pass
- // on the event as a key-down event to the plugin.
- record.what = keyDown;
- } else if (event->type() == eventNames().keyupEvent) {
- // PlatformKeyboardEvent::KeyUp events always have the text, so nothing
- // fancy here.
- record.what = keyUp;
- } else {
- return;
- }
-
- const PlatformKeyboardEvent* platformEvent = event->keyEvent();
- int keyCode = platformEvent->nativeVirtualKeyCode();
-
- const String text = platformEvent->text();
- if (text.length() < 1) {
- event->setDefaultHandled();
- return;
- }
-
- WTF::RetainPtr<CFStringRef> cfText(WTF::AdoptCF, text.createCFString());
-
- LOG(Plugins, "PV::hKE(): PKE.text: %s, PKE.unmodifiedText: %s, PKE.keyIdentifier: %s",
- text.ascii().data(), platformEvent->unmodifiedText().ascii().data(),
- platformEvent->keyIdentifier().ascii().data());
-
- char charCodes[2] = { 0, 0 };
- if (!CFStringGetCString(cfText.get(), charCodes, 2, CFStringGetSystemEncoding())) {
- LOG_ERROR("Could not resolve character code using system encoding.");
- event->setDefaultHandled();
- return;
- }
-
- record.where = globalMousePosForPlugin();
- record.modifiers = modifiersForEvent(event);
- record.message = ((keyCode & 0xFF) << 8) | (charCodes[0] & 0xFF);
- record.when = TickCount();
-
- LOG(Plugins, "PV::hKE(): record.modifiers: %d", record.modifiers);
-
-#if PLATFORM(QT)
- LOG(Plugins, "PV::hKE(): PKE.qtEvent()->nativeVirtualKey: 0x%02X, charCode: %d",
- keyCode, int(uchar(charCodes[0])));
-#endif
-
- if (!dispatchNPEvent(record))
- LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", record.what);
- else
- event->setDefaultHandled();
- } else
-#endif
- {
- NSEvent *currentEvent = [NSApp currentEvent];
- NPCocoaEventType eventType;
- NSEventType type = [currentEvent type];
-
- switch (type) {
- case NSKeyDown:
- eventType = NPCocoaEventKeyDown;
- m_keyDownSent = true;
- break;
- case NSKeyUp:
- if (m_disregardKeyUpCounter > 0) {
- m_disregardKeyUpCounter--;
- event->setDefaultHandled();
- return;
- }
- eventType = NPCocoaEventKeyUp;
- break;
- case NSFlagsChanged:
- eventType = NPCocoaEventFlagsChanged;
- break;
- default:
- return;
- }
-
- NPCocoaEvent cocoaEvent;
- initializeNPCocoaEvent(&cocoaEvent);
- cocoaEvent.type = eventType;
- if (eventType != NPCocoaEventFlagsChanged) {
- NSString *characters = [currentEvent characters];
- NSString *charactersIgnoringModifiers = [currentEvent charactersIgnoringModifiers];
- cocoaEvent.data.key.characters = reinterpret_cast<NPNSString*>(characters);
- cocoaEvent.data.key.charactersIgnoringModifiers = reinterpret_cast<NPNSString*>(charactersIgnoringModifiers);
- cocoaEvent.data.key.isARepeat = [currentEvent isARepeat];
- cocoaEvent.data.key.keyCode = [currentEvent keyCode];
- cocoaEvent.data.key.modifierFlags = getModifiers(event);
- }
-
- int16_t response = dispatchNPCocoaEvent(cocoaEvent);
- if(response == kNPEventNotHandled) {
- LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", cocoaEvent.type);
- } else if (response == kNPEventStartIME) {
- // increment counter and resend as a text input
- m_disregardKeyUpCounter++;
- NPCocoaEvent textEvent;
- initializeNPCocoaEvent(&textEvent);
- textEvent.type = NPCocoaEventTextInput;
- textEvent.data.text.text = reinterpret_cast<NPNSString*>([currentEvent characters]);
- response = dispatchNPCocoaEvent(textEvent);
- if(response == kNPEventNotHandled)
- LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", cocoaEvent.type);
- }
-
- // All keyboard events need to be handled to prevent them falling
- // through to the page, unless they are Meta key events, in which
- // case they are, unless they are Cmd+a. From WebKit2, possibly
- // not the most elegant piece of key handling code.....
- if (event->metaKey()) {
- if (cocoaEvent.data.key.keyCode == 0)
+
+ NSEvent *currentEvent = [NSApp currentEvent];
+ NPCocoaEventType eventType;
+ NSEventType type = [currentEvent type];
+
+ switch (type) {
+ case NSKeyDown:
+ eventType = NPCocoaEventKeyDown;
+ m_keyDownSent = true;
+ break;
+ case NSKeyUp:
+ if (m_disregardKeyUpCounter > 0) {
+ m_disregardKeyUpCounter--;
event->setDefaultHandled();
- } else {
- // else ignore, it's a Meta Key event for the browser.
- event->setDefaultHandled();
- }
+ return;
+ }
+ eventType = NPCocoaEventKeyUp;
+ break;
+ case NSFlagsChanged:
+ eventType = NPCocoaEventFlagsChanged;
+ break;
+ default:
+ return;
}
-}
-
-#ifndef NP_NO_CARBON
-void PluginView::nullEventTimerFired(Timer<PluginView>*)
-{
- EventRecord record;
-
- record.what = nullEvent;
- record.message = 0;
- record.when = TickCount();
- record.where = m_lastMousePos;
- record.modifiers = GetCurrentKeyModifiers();
- if (!Button())
- record.modifiers |= btnState;
-
- if (!dispatchNPEvent(record))
- LOG(Events, "PluginView::nullEventTimerFired(): Null event not accepted");
-}
-#endif
-
-#ifndef NP_NO_CARBON
-static int modifiersForEvent(UIEventWithKeyState* event)
-{
- int modifiers = 0;
-
- if (event->ctrlKey())
- modifiers |= controlKey;
- if (event->altKey())
- modifiers |= optionKey;
-
- if (event->metaKey())
- modifiers |= cmdKey;
-
- if (event->shiftKey())
- modifiers |= shiftKey;
-
- return modifiers;
-}
-#endif
-
-#ifndef NP_NO_CARBON
-Point PluginView::globalMousePosForPlugin() const
-{
- Point pos;
- GetGlobalMouse(&pos);
-
-#if PLATFORM(WX)
- // make sure the titlebar/toolbar size is included
- WindowRef windowRef = nativeWindowFor(platformPluginWidget());
- ::Rect content, structure;
-
- GetWindowBounds(windowRef, kWindowStructureRgn, &structure);
- GetWindowBounds(windowRef, kWindowContentRgn, &content);
-
- int top = content.top - structure.top;
- pos.v -= top;
-#endif
-
- return pos;
-}
-#endif
-
-#ifndef NP_NO_CARBON
-Point PluginView::mousePosForPlugin(MouseEvent* event) const
-{
- ASSERT(event);
- if (platformPluginWidget())
- return globalMousePosForPlugin();
-
- if (event->button() == 2) {
- // always pass the global position for right-click since Flash uses it to position the context menu
- return globalMousePosForPlugin();
+ NPCocoaEvent cocoaEvent;
+ initializeNPCocoaEvent(&cocoaEvent);
+ cocoaEvent.type = eventType;
+ if (eventType != NPCocoaEventFlagsChanged) {
+ NSString *characters = [currentEvent characters];
+ NSString *charactersIgnoringModifiers = [currentEvent charactersIgnoringModifiers];
+ cocoaEvent.data.key.characters = reinterpret_cast<NPNSString*>(characters);
+ cocoaEvent.data.key.charactersIgnoringModifiers = reinterpret_cast<NPNSString*>(charactersIgnoringModifiers);
+ cocoaEvent.data.key.isARepeat = [currentEvent isARepeat];
+ cocoaEvent.data.key.keyCode = [currentEvent keyCode];
+ cocoaEvent.data.key.modifierFlags = getModifiers(event);
}
- Point pos;
- IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation()));
- pos.h = postZoomPos.x() + m_windowRect.x();
- // The number 22 is the height of the title bar. As to why it figures in the calculation below
- // is left as an exercise to the reader :-)
- pos.v = postZoomPos.y() + m_windowRect.y() - 22;
- return pos;
-}
-#endif
-
-#ifndef NP_NO_CARBON
-bool PluginView::dispatchNPEvent(NPEvent& event)
-{
- PluginView::setCurrentPluginView(this);
- JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonJSGlobalData());
- setCallingPlugin(true);
-
- bool accepted = m_plugin->pluginFuncs()->event(m_instance, &event);
+ int16_t response = dispatchNPCocoaEvent(cocoaEvent);
+ if(response == kNPEventNotHandled) {
+ LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", cocoaEvent.type);
+ } else if (response == kNPEventStartIME) {
+ // increment counter and resend as a text input
+ m_disregardKeyUpCounter++;
+ NPCocoaEvent textEvent;
+ initializeNPCocoaEvent(&textEvent);
+ textEvent.type = NPCocoaEventTextInput;
+ textEvent.data.text.text = reinterpret_cast<NPNSString*>([currentEvent characters]);
+ response = dispatchNPCocoaEvent(textEvent);
+ if(response == kNPEventNotHandled)
+ LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", cocoaEvent.type);
+ }
- setCallingPlugin(false);
- PluginView::setCurrentPluginView(0);
- return accepted;
+ // All keyboard events need to be handled to prevent them falling
+ // through to the page, unless they are Meta key events, in which
+ // case they are, unless they are Cmd+a. From WebKit2, possibly
+ // not the most elegant piece of key handling code.....
+ if (event->metaKey()) {
+ if (cocoaEvent.data.key.keyCode == 0)
+ event->setDefaultHandled();
+ } else {
+ // else ignore, it's a Meta Key event for the browser.
+ event->setDefaultHandled();
+ }
}
-#endif
-
int16_t PluginView::dispatchNPCocoaEvent(NPCocoaEvent& cocoaEvent)
{