[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 14:14:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5d931660003374efb6d2a980dae8d66b82990798
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 5 21:42:35 2010 +0000

    Start sending Carbon plug-in events in th Carbon event model
    https://bugs.webkit.org/show_bug.cgi?id=47209
    <rdar://problem/8515677>
    
    Reviewed by Sam Weinig.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
    (WebKit::NetscapePlugin::NetscapePlugin):
    Initialize the NP_CGContext struct.
    
    * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
    (WebKit::NetscapePlugin::platformPostInitialize):
    Create a fake Carbon window.
    
    (WebKit::NetscapePlugin::platformDestroy):
    Destroy the Carbon window.
    
    (WebKit::modifiersForEvent):
    Given a WebEvent, return the EventRecord modifiers.
    
    (WebKit::NetscapePlugin::platformPaint):
    (WebKit::NetscapePlugin::platformHandleMouseEvent):
    (WebKit::NetscapePlugin::platformHandleWheelEvent):
    (WebKit::NetscapePlugin::platformHandleMouseEnterEvent):
    (WebKit::NetscapePlugin::platformHandleMouseLeaveEvent):
    (WebKit::NetscapePlugin::platformSetFocus):
    (WebKit::NetscapePlugin::windowFocusChanged):
    Create Carbon EventRecords and call NPP_HandleEvent.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69150 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 99c40ff..2dca3cb 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,34 @@
+2010-10-05  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Start sending Carbon plug-in events in th Carbon event model
+        https://bugs.webkit.org/show_bug.cgi?id=47209
+        <rdar://problem/8515677>
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin):
+        Initialize the NP_CGContext struct.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformPostInitialize):
+        Create a fake Carbon window.
+
+        (WebKit::NetscapePlugin::platformDestroy):
+        Destroy the Carbon window.
+
+        (WebKit::modifiersForEvent):
+        Given a WebEvent, return the EventRecord modifiers.
+
+        (WebKit::NetscapePlugin::platformPaint):
+        (WebKit::NetscapePlugin::platformHandleMouseEvent):
+        (WebKit::NetscapePlugin::platformHandleWheelEvent):
+        (WebKit::NetscapePlugin::platformHandleMouseEnterEvent):
+        (WebKit::NetscapePlugin::platformHandleMouseLeaveEvent):
+        (WebKit::NetscapePlugin::platformSetFocus):
+        (WebKit::NetscapePlugin::windowFocusChanged):
+        Create Carbon EventRecords and call NPP_HandleEvent.
+
 2010-10-05  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Mark Rowe.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 65fcace..18edc38 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -56,6 +56,9 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
 #if PLATFORM(MAC)
     , m_drawingModel(static_cast<NPDrawingModel>(-1))
     , m_eventModel(static_cast<NPEventModel>(-1))
+#ifndef NP_NO_CARBON
+    , m_npCGContext()
+#endif    
 #endif
 {
     m_npp.ndata = this;
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 60fc29e..f273755 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -55,6 +55,9 @@ public:
 #if PLATFORM(MAC)
     NPError setDrawingModel(NPDrawingModel);
     NPError setEventModel(NPEventModel);
+#ifndef NP_NO_CARBON
+    WindowRef windowRef() const;
+#endif
 #elif PLATFORM(WIN)
     HWND containingWindow() const;
 #endif
@@ -186,6 +189,9 @@ private:
     NPDrawingModel m_drawingModel;
     NPEventModel m_eventModel;
     RetainPtr<PlatformLayer> m_pluginLayer;
+#ifndef NP_NO_CARBON
+    NP_CGContext m_npCGContext;
+#endif
 #elif PLATFORM(WIN)
     HWND m_window;
 #endif
diff --git a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
index 1636ab2..a970bd4 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
+++ b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
@@ -25,7 +25,7 @@
 
 #include "NetscapePlugin.h"
 
-#include <AppKit/AppKit.h>
+#include "NotImplemented.h"
 #include "WebEvent.h"
 #include <WebCore/GraphicsContext.h>
 
@@ -122,11 +122,30 @@ bool NetscapePlugin::platformPostInitialize()
         }
     }
 
+#ifndef NP_NO_CARBON
+    if (m_eventModel == NPEventModelCarbon) {
+        // Initialize the fake Carbon window.
+        Rect bounds = { 0, 0, 0, 0 };
+        CreateNewWindow(kDocumentWindowClass, 0, &bounds, reinterpret_cast<WindowRef*>(&m_npCGContext.window));
+        
+        // FIXME: Disable the backing store.
+        
+        m_npWindow.window = &m_npCGContext;
+    }
+#endif
+
     return true;
 }
 
 void NetscapePlugin::platformDestroy()
 {
+#ifndef NP_NO_CARBON
+    if (m_eventModel == NPEventModelCarbon) {
+        // Destroy the fake Carbon window.
+        ASSERT(m_npCGContext.window);
+        DisposeWindow(static_cast<WindowRef>(m_npCGContext.window));
+    }
+#endif
 }
 
 void NetscapePlugin::platformGeometryDidChange()
@@ -143,8 +162,80 @@ static inline NPCocoaEvent initializeEvent(NPCocoaEventType type)
     return event;
 }
 
+#ifndef NP_NO_CARBON
+WindowRef NetscapePlugin::windowRef() const
+{
+    ASSERT(m_eventModel == NPEventModelCarbon);
+
+    return reinterpret_cast<WindowRef>(m_npCGContext.window);
+}
+
+static inline EventRecord initializeEventRecord(EventKind eventKind)
+{
+    EventRecord eventRecord;
+
+    eventRecord.what = eventKind;
+    eventRecord.message = 0;
+    eventRecord.when = TickCount();
+    eventRecord.where = Point();
+    eventRecord.modifiers = 0;
+
+    return eventRecord;
+}
+
+static bool anyMouseButtonIsDown(const WebEvent& event)
+{
+    if (event.type() == WebEvent::MouseDown)
+        return true;
+
+    if (event.type() == WebEvent::MouseMove && static_cast<const WebMouseEvent&>(event).button() != WebMouseEvent::NoButton)
+        return true;
+
+    return false;
+}
+
+static bool rightMouseButtonIsDown(const WebEvent& event)
+{
+    if (event.type() == WebEvent::MouseDown && static_cast<const WebMouseEvent&>(event).button() == WebMouseEvent::RightButton)
+        return true;
+    
+    if (event.type() == WebEvent::MouseMove && static_cast<const WebMouseEvent&>(event).button() == WebMouseEvent::RightButton)
+        return true;
+    
+    return false;
+}
+
+    
+static EventModifiers modifiersForEvent(const WebEvent& event)
+{
+    EventModifiers modifiers = 0;
+
+    // We only want to set the btnState if a mouse button is _not_ down.
+    if (!anyMouseButtonIsDown(event))
+        modifiers |= btnState;
+
+    if (event.metaKey())
+        modifiers |= cmdKey;
+
+    if (event.shiftKey())
+        modifiers |= shiftKey;
+
+    if (event.altKey())
+        modifiers |= optionKey;
+
+    // Set controlKey if the control key is down or the right mouse button is down.
+    if (event.controlKey() || rightMouseButtonIsDown(event))
+        modifiers |= controlKey;
+
+    return modifiers;
+}
+
+#endif
+
 void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect)
 {
+    CGContextRef platformContext = context->platformContext();
+
     // Translate the context so that the origin is at the top left corner of the plug-in view.
     context->translate(m_frameRect.x(), m_frameRect.y());
 
@@ -156,7 +247,7 @@ void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirt
 
             NPCocoaEvent event = initializeEvent(NPCocoaEventDrawRect);
 
-            event.data.draw.context = context->platformContext();
+            event.data.draw.context = platformContext;
             event.data.draw.x = dirtyRect.x() - m_frameRect.x();
             event.data.draw.y = dirtyRect.y() - m_frameRect.y();
             event.data.draw.width = dirtyRect.width();
@@ -165,7 +256,22 @@ void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirt
             NPP_HandleEvent(&event);
             break;
         }
-        
+
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon: {
+            if (platformContext != m_npCGContext.context) {
+                m_npCGContext.context = platformContext;
+                callSetWindow();
+            }
+
+            EventRecord event = initializeEventRecord(updateEvt);
+            event.message = reinterpret_cast<unsigned long>(windowRef());
+            
+            NPP_HandleEvent(&event);
+            break;            
+        }
+#endif
+
         default:
             ASSERT_NOT_REACHED();
     }
@@ -251,6 +357,13 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
             return NPP_HandleEvent(&event);
         }
 
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon: {
+            notImplemented();
+            return false;
+        }
+#endif
+
         default:
             ASSERT_NOT_REACHED();
     }
@@ -275,6 +388,12 @@ bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent& wheelEvent)
             return NPP_HandleEvent(&event);
         }
 
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon:
+            // Carbon doesn't have wheel events.
+            break;
+#endif
+
         default:
             ASSERT_NOT_REACHED();
     }
@@ -292,6 +411,15 @@ bool NetscapePlugin::platformHandleMouseEnterEvent(const WebMouseEvent& mouseEve
             return NPP_HandleEvent(&event);
         }
 
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon: {
+            EventRecord eventRecord = initializeEventRecord(adjustCursorEvent);
+            eventRecord.modifiers = modifiersForEvent(mouseEvent);
+            
+            return NPP_HandleEvent(&eventRecord);
+        }
+#endif
+
         default:
             ASSERT_NOT_REACHED();
     }
@@ -309,6 +437,15 @@ bool NetscapePlugin::platformHandleMouseLeaveEvent(const WebMouseEvent& mouseEve
             return NPP_HandleEvent(&event);
         }
 
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon: {
+            EventRecord eventRecord = initializeEventRecord(adjustCursorEvent);
+            eventRecord.modifiers = modifiersForEvent(mouseEvent);
+            
+            return NPP_HandleEvent(&eventRecord);
+        }
+#endif
+
         default:
             ASSERT_NOT_REACHED();
     }
@@ -384,6 +521,15 @@ void NetscapePlugin::platformSetFocus(bool hasFocus)
             break;
         }
 
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon: {
+            EventRecord event = initializeEventRecord(hasFocus ? getFocusEvent : loseFocusEvent);
+
+            NPP_HandleEvent(&event);
+            break;
+        }
+#endif
+            
         default:
             ASSERT_NOT_REACHED();
     }
@@ -400,6 +546,22 @@ void NetscapePlugin::windowFocusChanged(bool hasFocus)
             NPP_HandleEvent(&event);
             break;
         }
+        
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon: {
+            HiliteWindow(windowRef(), hasFocus);
+            if (hasFocus)
+                SetUserFocusWindow(windowRef());
+
+            EventRecord event = initializeEventRecord(activateEvt);
+            event.message = reinterpret_cast<unsigned long>(windowRef());
+            if (hasFocus)
+                event.modifiers |= activeFlag;
+            
+            NPP_HandleEvent(&event);
+            break;
+        }
+#endif
 
         default:
             ASSERT_NOT_REACHED();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list