Reviewed by Maciej.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2005 06:44:25 +0000 (06:44 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Feb 2005 06:44:25 +0000 (06:44 +0000)
        - fixed <rdar://problem/3993722> need oncut and onpaste handlers implemented for <textarea> (needed for widgets)

        * kwq/KWQTextArea.mm:
        (-[KWQTextAreaTextView dispatchHTMLEvent:]): Added.
        (-[KWQTextAreaTextView cut:]): Dispatch "before cut" and "cut" events.
        (-[KWQTextAreaTextView copy:]): Dispatch "before copy" and "copy" events.
        (-[KWQTextAreaTextView paste:]): Dispatch "before paste" and "paste" events.
        (-[KWQTextAreaTextView pasteAsPlainText:]): Ditto.
        (-[KWQTextAreaTextView pasteAsRichText:]): Ditto.

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

WebCore/ChangeLog-2005-08-23
WebCore/kwq/KWQTextArea.mm

index 4cdae2156f19d154e9fd5ab9c638a47acb721898..7bb08c70c3c2239ed769a43e8c60a9dd3337bfef 100644 (file)
@@ -1,3 +1,17 @@
+2005-02-06  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed <rdar://problem/3993722> need oncut and onpaste handlers implemented for <textarea> (needed for widgets)
+
+        * kwq/KWQTextArea.mm:
+        (-[KWQTextAreaTextView dispatchHTMLEvent:]): Added.
+        (-[KWQTextAreaTextView cut:]): Dispatch "before cut" and "cut" events.
+        (-[KWQTextAreaTextView copy:]): Dispatch "before copy" and "copy" events.
+        (-[KWQTextAreaTextView paste:]): Dispatch "before paste" and "paste" events.
+        (-[KWQTextAreaTextView pasteAsPlainText:]): Ditto.
+        (-[KWQTextAreaTextView pasteAsRichText:]): Ditto.
+
 2005-02-06  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej.
index d2ae8ffb82bb0c8f9fd62b71fdfd9bf7db50db45..85dd79c04b40068270ff29ccc0a0d46820bf61d6 100644 (file)
 #import "KWQKHTMLPart.h"
 #import "KWQNSViewExtras.h"
 #import "KWQTextEdit.h"
+#import "render_replaced.h"
 #import "WebCoreBridge.h"
 
+using DOM::EventImpl;
+using DOM::NodeImpl;
+using khtml::RenderWidget;
+
 /*
     This widget is used to implement the <TEXTAREA> element.
     
@@ -64,6 +69,7 @@
     QTextEdit *widget;
     BOOL disabled;
     BOOL editableIfEnabled;
+    BOOL inCut;
 }
 
 - (void)setWidget:(QTextEdit *)widget;
@@ -765,6 +771,63 @@ static NSString *WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckin
     [[self textStorage] setForegroundColor:color];
 }
 
+// Could get fancy and send this to QTextEdit, then RenderTextArea, but there's really no harm
+// in doing this directly right here. Could refactor some day if you disagree.
+
+// FIXME: This does not yet implement the feature of canceling the operation, or the necessary
+// support to implement the clipboard operations entirely in JavaScript.
+- (void)dispatchHTMLEvent:(EventImpl::EventId)eventID
+{
+    if (widget) {
+        const RenderWidget *rw = static_cast<const RenderWidget *>(widget->eventFilterObject());
+        if (rw) {
+            NodeImpl *node = rw->element();
+            if (node) {
+                node->dispatchHTMLEvent(eventID, false, false);
+            }
+        }
+    }
+}
+
+- (void)cut:(id)sender
+{
+    inCut = YES;
+    [self dispatchHTMLEvent:EventImpl::BEFORECUT_EVENT];
+    [super cut:sender];
+    [self dispatchHTMLEvent:EventImpl::CUT_EVENT];
+    inCut = NO;
+}
+
+- (void)copy:(id)sender
+{
+    if (!inCut)
+        [self dispatchHTMLEvent:EventImpl::BEFORECOPY_EVENT];
+    [super copy:sender];
+    if (!inCut)
+        [self dispatchHTMLEvent:EventImpl::COPY_EVENT];
+}
+
+- (void)paste:(id)sender
+{
+    [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+    [super paste:sender];
+    [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+}
+
+- (void)pasteAsPlainText:(id)sender
+{
+    [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+    [super pasteAsPlainText:sender];
+    [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+}
+
+- (void)pasteAsRichText:(id)sender
+{
+    [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+    [super pasteAsRichText:sender];
+    [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+}
+
 @end
 
 @implementation NSView (KWQTextArea)