WebCore:
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2009 18:44:19 +0000 (18:44 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2009 18:44:19 +0000 (18:44 +0000)
2009-03-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/6610666> Revise the Cocoa event model text API

        Add a NPCocoaEventTextInput event type. Remove the text input variables.

        * bridge/npapi.h:
        (_NPCocoaEvent::):

WebKit:

2009-03-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/6610666> Revise the Cocoa event model text API

        Remove nptextinput.h

        * WebKit.xcodeproj/project.pbxproj:

WebKit/mac:

2009-03-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/6610666> Revise the Cocoa event model text API

        Replace the text input API with a simpler API that uses a separate text input window.

        * Plugins/WebNetscapePluginEventHandlerCocoa.h:
        * Plugins/WebNetscapePluginEventHandlerCocoa.mm:
        (WebNetscapePluginEventHandlerCocoa::WebNetscapePluginEventHandlerCocoa):
        Initialize m_keyEventHandler to 0.

        (WebNetscapePluginEventHandlerCocoa::keyDown):
        If the plug-in returns 0 from NPP_HandleEvent, pass the event to the TSM machinery.

        (WebNetscapePluginEventHandlerCocoa::focusChanged):
        Install/remove the key event handler as needed.

        (WebNetscapePluginEventHandlerCocoa::handleTSMEvent):
        Get the text and send a TextInput event.

        * Plugins/WebNetscapePluginView.h:
        * Plugins/WebNetscapePluginView.mm:
        Remove the old text input API.

        (-[WebNetscapePluginView inputContext]):
        Always return nil here.

        * Plugins/npapi.mm:
        * Plugins/nptextinput.h: Removed.

WebKitTools:

2009-03-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Dan Bernstein.

        <rdar://problem/6610666> Revise the Cocoa event model text API

        Add a case statement for NPCocoaEventTextInput.

        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
        (handleEventCocoa):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41674 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
WebCore/ChangeLog
WebCore/bridge/npapi.h
WebKit/ChangeLog
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/mac/ChangeLog
WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.h
WebKit/mac/Plugins/WebNetscapePluginEventHandlerCocoa.mm
WebKit/mac/Plugins/WebNetscapePluginView.h
WebKit/mac/Plugins/WebNetscapePluginView.mm
WebKit/mac/Plugins/npapi.mm
WebKit/mac/Plugins/nptextinput.h [deleted file]
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp

index aaa529e93ccf25db374049d01c202423a1459dcc..5d19408e6abc3e56aeed89721f3d85fbd268208f 100644 (file)
@@ -1,3 +1,14 @@
+2009-03-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/6610666> Revise the Cocoa event model text API
+        
+        Add a NPCocoaEventTextInput event type. Remove the text input variables.
+        
+        * bridge/npapi.h:
+        (_NPCocoaEvent::):
+
 2009-03-13  Kevin Decker  <kdecker@apple.com>
 
         Reviewed by Anders.
index bce5b8e4c9a8ed70745db1c4ff583d776cde5efc..9f2da04abd4ef078d7344af3d92618e2fbe58b31 100644 (file)
@@ -351,8 +351,6 @@ typedef enum {
     NPPVpluginDrawingModel = 1000,
     /* Used for negotiating event models */
     NPPVpluginEventModel = 1001,
-    /* The plug-in text input vtable */
-    NPPVpluginTextInputFuncs = 1002,
     /* In the NPDrawingModelCoreAnimation drawing model, the browser asks the plug-in for a Core Animation layer. */
     NPPVpluginCoreAnimationLayer = 1003
 #endif
@@ -401,7 +399,6 @@ typedef enum {
 #endif
     , NPNVsupportsCocoaBool = 3001 /* TRUE if the browser supports the Cocoa event model */
     
-    , NPNVbrowserTextInputFuncs = 1002 /* The browser text input vtable */
 #endif /* XP_MACOSX */
 } NPNVariable;
 
@@ -459,6 +456,7 @@ typedef enum {
     NPCocoaEventFocusChanged,
     NPCocoaEventWindowFocusChanged,
     NPCocoaEventScrollWheel,
+    NPCocoaEventTextInput
 } NPCocoaEventType;
 
 typedef struct _NPNSString NPNSString;
@@ -495,7 +493,10 @@ typedef struct _NPCocoaEvent {
         } draw;
         struct {
             NPBool hasFocus;
-        } focus;        
+        } focus;
+        struct {
+            NPNSString *text;
+        } text;
     } data;
 } NPCocoaEvent;
 
index b1d7afc7014a04f1c9bd17a45a58c1ef8cdfe348..51bc1deb8f2ff6fe20bd8b0871d63afe4703c84c 100644 (file)
@@ -1,3 +1,13 @@
+2009-03-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/6610666> Revise the Cocoa event model text API
+        
+        Remove nptextinput.h
+        
+        * WebKit.xcodeproj/project.pbxproj:
+
 2009-03-03  David Kilzer  <ddkilzer@apple.com>
 
         <rdar://problem/6581203> WebCore and WebKit should install the same set of headers during installhdrs phase as build phase
index c0221224f5af9dd764a8d9c48c47a3fd7f4e60b5..4e3d3a4a053888241686124fffdd43c6a8e87f2b 100644 (file)
@@ -27,7 +27,6 @@
                1A74A28F0F4F75400082E228 /* WebTextInputWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A74A28D0F4F75400082E228 /* WebTextInputWindowController.m */; };
                1A77B02E0EE7730500C8A1F9 /* WebPluginRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A77B02C0EE7730500C8A1F9 /* WebPluginRequest.h */; };
                1A77B02F0EE7730500C8A1F9 /* WebPluginRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A77B02D0EE7730500C8A1F9 /* WebPluginRequest.m */; };
-               1A7F9C4C0DD3DDEA0028F8A5 /* nptextinput.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A7F9C4B0DD3DDEA0028F8A5 /* nptextinput.h */; settings = {ATTRIBUTES = (Public, ); }; };
                1A8DED500EE88B8A00F25022 /* HostedNetscapePluginStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8DED4E0EE88B8A00F25022 /* HostedNetscapePluginStream.h */; };
                1A8DED510EE88B8A00F25022 /* HostedNetscapePluginStream.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A8DED4F0EE88B8A00F25022 /* HostedNetscapePluginStream.mm */; };
                1AAF58940EDCCF15008D883D /* WebKitPluginAgent.defs in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF588A0EDCCEA3008D883D /* WebKitPluginAgent.defs */; settings = {ATTRIBUTES = (Private, ); }; };
                1A74A28D0F4F75400082E228 /* WebTextInputWindowController.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = WebTextInputWindowController.m; sourceTree = "<group>"; };
                1A77B02C0EE7730500C8A1F9 /* WebPluginRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPluginRequest.h; sourceTree = "<group>"; };
                1A77B02D0EE7730500C8A1F9 /* WebPluginRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebPluginRequest.m; sourceTree = "<group>"; };
-               1A7F9C4B0DD3DDEA0028F8A5 /* nptextinput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nptextinput.h; sourceTree = "<group>"; };
                1A8DED4E0EE88B8A00F25022 /* HostedNetscapePluginStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HostedNetscapePluginStream.h; sourceTree = "<group>"; };
                1A8DED4F0EE88B8A00F25022 /* HostedNetscapePluginStream.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HostedNetscapePluginStream.mm; sourceTree = "<group>"; };
                1AAF588A0EDCCEA3008D883D /* WebKitPluginAgent.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; path = WebKitPluginAgent.defs; sourceTree = "<group>"; };
                                1A77B02C0EE7730500C8A1F9 /* WebPluginRequest.h */,
                                1A77B02D0EE7730500C8A1F9 /* WebPluginRequest.m */,
                                F5F717230288493C018635CA /* npapi.mm */,
-                               1A7F9C4B0DD3DDEA0028F8A5 /* nptextinput.h */,
                        );
                        name = "Netscape Plug-ins";
                        sourceTree = "<group>";
                                939810460824BF01008DF038 /* WebViewFactory.h in Headers */,
                                9398109B0824BF01008DF038 /* WebViewInternal.h in Headers */,
                                939810710824BF01008DF038 /* WebViewPrivate.h in Headers */,
-                               1A7F9C4C0DD3DDEA0028F8A5 /* nptextinput.h in Headers */,
                                1A2DBE9F0F251E3A0036F8A6 /* ProxyInstance.h in Headers */,
                                1A74A28E0F4F75400082E228 /* WebTextInputWindowController.h in Headers */,
                        );
index ee829a6e44870552670baebe1aa121ea783011c4..b61c75f6d48bb991a00adfb59a617f7ac640cd95 100644 (file)
@@ -1,3 +1,35 @@
+2009-03-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/6610666> Revise the Cocoa event model text API
+
+        Replace the text input API with a simpler API that uses a separate text input window.
+        
+        * Plugins/WebNetscapePluginEventHandlerCocoa.h:
+        * Plugins/WebNetscapePluginEventHandlerCocoa.mm:
+        (WebNetscapePluginEventHandlerCocoa::WebNetscapePluginEventHandlerCocoa):
+        Initialize m_keyEventHandler to 0.
+        
+        (WebNetscapePluginEventHandlerCocoa::keyDown):
+        If the plug-in returns 0 from NPP_HandleEvent, pass the event to the TSM machinery.
+        
+        (WebNetscapePluginEventHandlerCocoa::focusChanged):
+        Install/remove the key event handler as needed.
+        
+        (WebNetscapePluginEventHandlerCocoa::handleTSMEvent):
+        Get the text and send a TextInput event.
+        
+        * Plugins/WebNetscapePluginView.h:
+        * Plugins/WebNetscapePluginView.mm:
+        Remove the old text input API.
+        
+        (-[WebNetscapePluginView inputContext]):
+        Always return nil here.
+        
+        * Plugins/npapi.mm:
+        * Plugins/nptextinput.h: Removed.
+
 2009-03-12  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Mike Thole and Mark Rowe.
index 8b6f6e74d88fbfa3225fb4d8afcd751dc82e02cf..c370024b922f27f76efe0aab30a08e0c1dd664c5 100644 (file)
@@ -53,10 +53,19 @@ public:
     virtual void focusChanged(bool hasFocus);
 
     virtual void* platformWindow(NSWindow*);
+    
 private:
     bool sendMouseEvent(NSEvent*, NPCocoaEventType);
     bool sendKeyEvent(NSEvent*, NPCocoaEventType);
     bool sendEvent(NPCocoaEvent*);
+    
+    void installKeyEventHandler();
+    void removeKeyEventHandler();
+    
+    static OSStatus TSMEventHandler(EventHandlerCallRef, EventRef, void *eventHandler);
+    OSStatus handleTSMEvent(EventRef);
+
+    EventHandlerRef m_keyEventHandler;
 };
 
 #endif //WebNetscapePluginEventHandlerCocoa_h
index 288a356e3d31448678115d2e639f0350457b3f48..f91a871f4c83a473b89cbb7979abed2b87ee47ba 100644 (file)
 
 #import "WebNetscapePluginEventHandlerCocoa.h"
 
+#import "WebKitSystemInterface.h"
 #import "WebNetscapePluginView.h"
+#import <wtf/Vector.h>
 
 WebNetscapePluginEventHandlerCocoa::WebNetscapePluginEventHandlerCocoa(WebNetscapePluginView* pluginView)
     : WebNetscapePluginEventHandler(pluginView)
+    , m_keyEventHandler(0)
 {
 }
 
@@ -118,8 +121,8 @@ void WebNetscapePluginEventHandlerCocoa::keyDown(NSEvent *event)
     bool retval = sendKeyEvent(event, NPCocoaEventKeyDown);
     
     // If the plug-in did not handle the event, pass it on to the Input Manager.
-    if (!retval)
-        [m_pluginView interpretKeyEvents:[NSArray arrayWithObject:event]];
+    if (retval)
+        WKSendKeyEventToTSM(event);
 }
 
 void WebNetscapePluginEventHandlerCocoa::keyUp(NSEvent *event)
@@ -173,6 +176,11 @@ void WebNetscapePluginEventHandlerCocoa::focusChanged(bool hasFocus)
     event.data.focus.hasFocus = hasFocus;
     
     sendEvent(&event);
+    
+    if (hasFocus)
+        installKeyEventHandler();
+    else
+        removeKeyEventHandler();
 }
 
 void* WebNetscapePluginEventHandlerCocoa::platformWindow(NSWindow* window)
@@ -202,4 +210,63 @@ bool WebNetscapePluginEventHandlerCocoa::sendEvent(NPCocoaEvent* event)
     return result;
 }
 
+void WebNetscapePluginEventHandlerCocoa::installKeyEventHandler()
+{
+    static const EventTypeSpec TSMEvents[] =
+    {
+        { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }
+    };
+    
+    if (!m_keyEventHandler)
+        InstallEventHandler(GetWindowEventTarget((WindowRef)[[m_pluginView window] windowRef]),
+                            NewEventHandlerUPP(TSMEventHandler),
+                            GetEventTypeCount(TSMEvents),
+                            TSMEvents,
+                            this,
+                            &m_keyEventHandler);
+}
+
+void WebNetscapePluginEventHandlerCocoa::removeKeyEventHandler()
+{
+    if (m_keyEventHandler) {
+        RemoveEventHandler(m_keyEventHandler);
+        m_keyEventHandler = 0;
+    }    
+}
+
+OSStatus WebNetscapePluginEventHandlerCocoa::TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef event, void* eventHandler)
+{
+    return static_cast<WebNetscapePluginEventHandlerCocoa*>(eventHandler)->handleTSMEvent(event);
+}
+
+OSStatus WebNetscapePluginEventHandlerCocoa::handleTSMEvent(EventRef eventRef)
+{
+    ASSERT(GetEventKind(eventRef) == kEventTextInputUnicodeForKeyEvent);
+    
+    // Get the text buffer size.
+    ByteCount size;
+    OSStatus result = GetEventParameter(eventRef, kEventParamTextInputSendText, typeUnicodeText, 0, 0, &size, 0);
+    if (result != noErr)
+        return result;
+    
+    unsigned length = size / sizeof(UniChar);
+    Vector<UniChar, 16> characters(length);
+    
+    // Now get the actual text.
+    result = GetEventParameter(eventRef, kEventParamTextInputSendText, typeUnicodeText, 0, size, 0, characters.data());
+    if (result != noErr)
+        return result;
+
+    RetainPtr<CFStringRef> text(AdoptCF, CFStringCreateWithCharacters(0, characters.data(), length));
+
+    NPCocoaEvent event;
+    
+    initializeEvent(&event, NPCocoaEventTextInput);
+    event.data.text.text = (NPNSString*)text.get();
+    
+    sendEvent(&event);
+
+    return noErr;
+}
+
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
index eec6c9b6fb9d4d72dc08aa4cba341e748dfabc1d..233400f8f02d3bf0db85b78959fe36b150ee613f 100644 (file)
@@ -52,14 +52,12 @@ typedef union PluginPort {
     NP_CGContext cgPort;
 } PluginPort;
 
-typedef struct _NPPluginTextInputFuncs NPPluginTextInputFuncs;
-
 // Because the Adobe 7.x Acrobat plug-in has a hard coded check for a view named 
 // "WebNetscapePluginDocumentView", this class must retain the old name in order 
 // for the plug-in to function correctly. (rdar://problem/4699455)
 #define WebNetscapePluginView WebNetscapePluginDocumentView
 
-@interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader, NSTextInput>
+@interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader>
 {
     RefPtr<WebNetscapePluginStream> _manualStream;
 #ifndef BUILDING_ON_TIGER
@@ -102,8 +100,6 @@ typedef struct _NPPluginTextInputFuncs NPPluginTextInputFuncs;
     RetainPtr<NSMutableDictionary> _pendingFrameLoads;
     
     BOOL _isSilverlight;
-    
-    NPPluginTextInputFuncs *textInputFuncs;
 }
 
 + (WebNetscapePluginView *)currentPluginView;
index c35e47482c8d40916fe7a648a142021472061a25..3ded1b4cb9697b1173f622208b735f1a8d50e840 100644 (file)
@@ -67,7 +67,6 @@
 #import <WebCore/ScriptController.h>
 #import <WebCore/SoftLinking.h> 
 #import <WebCore/WebCoreObjCExtras.h>
-#import <WebKit/nptextinput.h>
 #import <WebKit/DOMPrivate.h>
 #import <WebKit/WebUIDelegate.h>
 #import <runtime/InitializeThreading.h>
@@ -1054,19 +1053,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     
     // Create the event handler
     _eventHandler.set(WebNetscapePluginEventHandler::create(self));
-    
-    // Get the text input vtable
-    if (eventModel == NPEventModelCocoa) {
-        [self willCallPlugInFunction];
-        {
-            JSC::JSLock::DropAllLocks dropAllLocks(false);
-            NPPluginTextInputFuncs *value = 0;
-            if (![_pluginPackage.get() pluginFuncs]->getvalue(plugin, NPPVpluginTextInputFuncs, &value) == NPERR_NO_ERROR && value)
-                textInputFuncs = value;
-        }
-        [self didCallPlugInFunction];
-    }
-    
+        
     return YES;
 }
 
@@ -1139,8 +1126,6 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     [_pluginPackage.get() close];
     
     _eventHandler.clear();
-    
-    textInputFuncs = 0;
 }
 
 - (NPEventModel)eventModel
@@ -1408,160 +1393,11 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
         _manualStream->didFinishLoading(0);
 }
 
-#pragma mark NSTextInput implementation
-
 - (NSTextInputContext *)inputContext
 {
-#ifndef NP_NO_CARBON
-    if (!_isStarted || eventModel == NPEventModelCarbon)
-        return nil;
-#endif
-
-    return [super inputContext];
-}
-
-- (BOOL)hasMarkedText
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-    
-    if (textInputFuncs && textInputFuncs->hasMarkedText)
-        return textInputFuncs->hasMarkedText(plugin);
-    
-    return NO;
-}
-
-- (void)insertText:(id)aString
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-    
-    if (textInputFuncs && textInputFuncs->insertText)
-        textInputFuncs->insertText(plugin, aString);
-}
-
-- (NSRange)markedRange
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-
-    if (textInputFuncs && textInputFuncs->markedRange)
-        return textInputFuncs->markedRange(plugin);
-    
-    return NSMakeRange(NSNotFound, 0);
-}
-
-- (NSRange)selectedRange
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-
-    if (textInputFuncs && textInputFuncs->selectedRange)
-        return textInputFuncs->selectedRange(plugin);
-
-    return NSMakeRange(NSNotFound, 0);
-}    
-
-- (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-
-    if (textInputFuncs && textInputFuncs->setMarkedText)
-        textInputFuncs->setMarkedText(plugin, aString, selRange);
-}
-
-- (void)unmarkText
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-    
-    if (textInputFuncs && textInputFuncs->unmarkText)
-        textInputFuncs->unmarkText(plugin);
-}
-
-- (NSArray *)validAttributesForMarkedText
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-        
-    if (textInputFuncs && textInputFuncs->validAttributesForMarkedText)
-        return textInputFuncs->validAttributesForMarkedText(plugin);
-    
-    return [NSArray array];
-}
-
-- (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-    
-    if (textInputFuncs && textInputFuncs->attributedSubstringFromRange)
-        return textInputFuncs->attributedSubstringFromRange(plugin, theRange);
-
     return nil;
 }
 
-- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-
-    if (textInputFuncs && textInputFuncs->characterIndexForPoint) {
-        // Convert the point to window coordinates
-        NSPoint point = [[self window] convertScreenToBase:thePoint];
-        
-        // And view coordinates
-        point = [self convertPoint:point fromView:nil];
-        
-        return textInputFuncs->characterIndexForPoint(plugin, point);
-    }        
-
-    return NSNotFound;
-}
-
-- (void)doCommandBySelector:(SEL)aSelector
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-
-    if (textInputFuncs && textInputFuncs->doCommandBySelector)
-        textInputFuncs->doCommandBySelector(plugin, aSelector);
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)theRange
-{
-    ASSERT(eventModel == NPEventModelCocoa);
-    ASSERT(_isStarted);
-
-    if (textInputFuncs && textInputFuncs->firstRectForCharacterRange) {
-        NSRect rect = textInputFuncs->firstRectForCharacterRange(plugin, theRange);
-        
-        // Convert the rect to window coordinates
-        rect = [self convertRect:rect toView:nil];
-        
-        // Convert the rect location to screen coordinates
-        rect.origin = [[self window] convertBaseToScreen:rect.origin];
-        
-        return rect;
-    }
-
-    return NSZeroRect;
-}
-
-// test for 10.4 because of <rdar://problem/4243463>
-#ifdef BUILDING_ON_TIGER
-- (long)conversationIdentifier
-{
-    return (long)self;
-}
-#else
-- (NSInteger)conversationIdentifier
-{
-    return (NSInteger)self;
-}
-#endif
-
 @end
 
 @implementation WebNetscapePluginView (WebNPPCallbacks)
@@ -1997,18 +1833,6 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     [[self window] displayIfNeeded];
 }
 
-static NPBrowserTextInputFuncs *browserTextInputFuncs()
-{
-    static NPBrowserTextInputFuncs inputFuncs = {
-        0,
-        sizeof(NPBrowserTextInputFuncs),
-        NPN_MarkedTextAbandoned,
-        NPN_MarkedTextSelectionChanged
-    };
-    
-    return &inputFuncs;
-}
-
 - (NPError)getVariable:(NPNVariable)variable value:(void *)value
 {
     switch (variable) {
@@ -2093,14 +1917,7 @@ static NPBrowserTextInputFuncs *browserTextInputFuncs()
             *(NPBool *)value = TRUE;
             return NPERR_NO_ERROR;
         }
-            
-        case NPNVbrowserTextInputFuncs:
-        {
-            if (eventModel == NPEventModelCocoa) {
-                *(NPBrowserTextInputFuncs **)value = browserTextInputFuncs();
-                return NPERR_NO_ERROR;
-            }
-        }
+
         default:
             break;
     }
index eb32c2bc1db49d1acc42b35a28f71b6ab1dc6ae4..79eff2a3cf1d0511dd024b5209c9d3841b0ca3d4 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
 #import <WebKit/npapi.h>
-#import <WebKit/nptextinput.h>
 
 #import "WebNetscapePluginView.h"
 #import "WebKitLogging.h"
@@ -192,18 +191,4 @@ NPError NPN_PopUpContextMenu(NPP instance, NPMenu *menu)
     return [pluginViewForInstance(instance) popUpContextMenu:menu];
 }
 
-void NPN_MarkedTextAbandoned(NPP instance)
-{
-    WebNetscapePluginView *pluginView = pluginViewForInstance(instance);
-    
-    [[NSInputManager currentInputManager] markedTextAbandoned:pluginView];
-}
-
-void NPN_MarkedTextSelectionChanged(NPP instance, NSRange newSel)
-{
-    WebNetscapePluginView *pluginView = pluginViewForInstance(instance);
-    
-    [[NSInputManager currentInputManager] markedTextSelectionChanged:newSel client:pluginView];
-}
-
 #endif
diff --git a/WebKit/mac/Plugins/nptextinput.h b/WebKit/mac/Plugins/nptextinput.h
deleted file mode 100644 (file)
index 2ed3146..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2008, Apple Inc. and The Mozilla Foundation. 
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of Apple Inc. ("Apple") or The Mozilla
- * Foundation ("Mozilla") nor the names of their contributors may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
- * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-#ifndef __OBJC__
-#error "npinput.h can only be included from Objective-C code."
-#endif
-
-#ifndef _NP_TEXTINPUT_H_
-#define _NP_TEXTINPUT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <WebKit/npapi.h>
-
-#import <Cocoa/Cocoa.h>
-
-typedef void (*NPP_InsertTextFunc)(NPP npp, id aString);
-typedef void (*NPP_DoCommandBySelectorFunc)(NPP npp, SEL aSelector);
-typedef void (*NPP_SetMarkedTextFunc)(NPP npp, id aString, NSRange selRange);
-typedef void (*NPP_UnmarkTextFunc)(NPP npp);
-typedef BOOL (*NPP_HasMarkedTextFunc)(NPP npp);
-typedef NSAttributedString * (*NPP_AttributedSubstringFromRangeFunc)(NPP npp, NSRange theRange);
-typedef NSRange (*NPP_MarkedRangeFunc)(NPP npp);
-typedef NSRange (*NPP_SelectedRangeFunc)(NPP npp);
-typedef NSRect (*NPP_FirstRectForCharacterRangeFunc)(NPP npp, NSRange theRange);
-typedef unsigned long long (*NPP_CharacterIndexForPointFunc)(NPP npp, NSPoint thePoint);
-typedef NSArray *(*NPP_ValidAttributesForMarkedTextFunc)(NPP npp);
-
-typedef struct _NPPluginTextInputFuncs {
-    uint16 size;
-    uint16 version;
-    
-    NPP_InsertTextFunc insertText;
-    NPP_DoCommandBySelectorFunc doCommandBySelector;
-    NPP_SetMarkedTextFunc setMarkedText;
-    NPP_UnmarkTextFunc unmarkText;
-    NPP_HasMarkedTextFunc hasMarkedText;
-    NPP_AttributedSubstringFromRangeFunc attributedSubstringFromRange;
-    NPP_MarkedRangeFunc markedRange;
-    NPP_SelectedRangeFunc selectedRange;
-    NPP_FirstRectForCharacterRangeFunc firstRectForCharacterRange;
-    NPP_CharacterIndexForPointFunc characterIndexForPoint;
-    NPP_ValidAttributesForMarkedTextFunc validAttributesForMarkedText;
-} NPPluginTextInputFuncs;
-
-void NPP_InsertText(NPP npp, id aString);
-void NPP_DoCommandBySelector(NPP npp, SEL aSelector);
-void NPP_SetMarkedText(NPP npp, id aString, NSRange selRange);
-void NPP_UnmarkText(NPP npp);
-BOOL NPP_HasMarkedText(NPP npp);
-NSAttributedString *NPP_AttributedSubstringFromRange(NPP npp, NSRange theRange);
-NSRange NPP_MarkedRange(NPP npp);
-NSRange NPP_SelectedRange(NPP npp);
-NSRect NPP_FirstRectForCharacterRange(NPP npp, NSRange theRange);
-unsigned long long NPP_CharacterIndexForPoint(NPP npp, NSPoint thePoint);
-NSArray *NPP_ValidAttributesForMarkedText(NPP npp);
-
-typedef void (*NPN_MarkedTextAbandonedFunc)(NPP npp);
-typedef void (*NPN_MarkedTextSelectionChangedFunc)(NPP npp, NSRange newSel);
-
-typedef struct _NPBrowserTextInputFuncs {
-    uint16 size;
-    uint16 version;
-    
-    NPN_MarkedTextAbandonedFunc markedTextAbandoned;
-    NPN_MarkedTextSelectionChangedFunc markedTextSelectionChanged;
-} NPBrowserTextInputFuncs;
-
-void NPN_MarkedTextAbandoned(NPP npp);
-void NPN_MarkedTextSelectionChanged(NPP npp, NSRange newSel);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
index 7f05e9aa9bdffbdecf92c1534f0653aff9fcaa1f..fd3776bec28c0b9b6d2848a3f45f0602caad158e 100644 (file)
@@ -1,3 +1,14 @@
+2009-03-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        <rdar://problem/6610666> Revise the Cocoa event model text API
+
+        Add a case statement for NPCocoaEventTextInput.
+        
+        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
+        (handleEventCocoa):
+
 2009-03-12  Kevin Ollivier  <kevino@theolliviers.com>
 
         wx build fix. Let DerivedSources.make know we want database APIs.
index 9f698ba0c2ab502a341a5f1953c3910ab7f10713..aa8eb1f3fcc1860a3654375681fc8a56a1fa2bc8 100644 (file)
@@ -330,6 +330,7 @@ static int16_t handleEventCocoa(PluginObject* obj, NPCocoaEvent* event)
         case NPCocoaEventMouseExited:
         case NPCocoaEventMouseDragged:
         case NPCocoaEventScrollWheel:
+        case NPCocoaEventTextInput:
             return 1;
     }