[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/unity/WebKit/WebCore/platform/qt
From:       Nikolas Zimmermann <wildfox () kde ! org>
Date:       2006-08-04 19:18:42
Message-ID: 1154719122.010181.1306.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 569777 by wildfox:

Make keyboard events & javascript work...


 M  +14 -8     CanvasQt.cpp  
 M  +32 -0     FrameQt.cpp  
 M  +1 -1      FrameQt.h  


--- branches/work/unity/WebKit/WebCore/platform/qt/CanvasQt.cpp #569776:569777
@@ -3,6 +3,8 @@
  * Copyright (C) 2006 George Staikos <staikos@kde.org>
  * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
  * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,7 +33,7 @@
 
 #include <config.h>
 #include "FrameView.h"
-#include "Frame.h"
+#include "FrameQt.h"
 #include "TypingCommand.h"
 #include "KeyboardCodes.h"
 #include "GraphicsContext.h"
@@ -56,9 +58,9 @@
 void CanvasQt::paintEvent(QPaintEvent *ev)
 {
     FrameView *fv = static_cast<FrameView*>(m_frameView);
-    if (!fv || !fv->frame()) {
+    if (!fv || !fv->frame())
         return;
-    }
+
     QRect clip = ev->rect();
     QPainter p(this);
     GraphicsContext ctx(&p);
@@ -70,12 +72,12 @@
     return QSize(1024, 768);
 }
 
-
 void CanvasQt::mouseMoveEvent(QMouseEvent *ev)
 {
     FrameView *fv = static_cast<FrameView*>(m_frameView);
     if (!fv || !fv->frame())
         return;
+
     fv->handleMouseMoveEvent(PlatformMouseEvent(ev, 0));
 }
 
@@ -84,6 +86,7 @@
     FrameView *fv = static_cast<FrameView*>(m_frameView);
     if (!fv || !fv->frame())
         return;
+
     fv->handleMousePressEvent(PlatformMouseEvent(ev, 1));
 }
 
@@ -92,6 +95,7 @@
     FrameView *fv = static_cast<FrameView*>(m_frameView);
     if (!fv || !fv->frame())
         return;
+
     fv->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
 }
 
@@ -108,14 +112,15 @@
 void CanvasQt::handleKeyEvent(QKeyEvent *ev, bool isKeyUp)
 {
     PlatformKeyboardEvent kevent(ev, isKeyUp);
-    bool handled = false;
 
     FrameView *fv = static_cast<FrameView*>(m_frameView);
-    Frame *frame = (fv ? fv->frame() : 0);
+    FrameQt *frame = (fv ? static_cast<FrameQt*>(fv->frame()) : 0);
     if (!frame)
         return;
 
-    if (!kevent.isKeyUp()) {
+    bool handled = frame->keyEvent(kevent);
+
+    if (!handled && !kevent.isKeyUp()) {
         Node* start = frame->selection().start().node();
         if (start && start->isContentEditable()) {
             switch(kevent.WindowsKeyCode()) {
@@ -143,7 +148,8 @@
             }
             handled = true;
         }
-        qDebug() << "HANDLED: " << handled;
+        
+        // TODO: doScroll stuff()!
     }
 }
 
--- branches/work/unity/WebKit/WebCore/platform/qt/FrameQt.cpp #569776:569777
@@ -3,6 +3,7 @@
  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
  * Copyright (C) 2006 George Staikos <staikos@kde.org>
  * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
+ *
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,6 +36,7 @@
 #include "RenderLayer.h"
 #include "Page.h"
 #include "Document.h"
+#include "HTMLElement.h"
 #include "DOMWindow.h"
 #include "DOMImplementation.h"
 #include "BrowserExtensionQt.h"
@@ -491,6 +493,36 @@
     return false;
 }
 
+bool FrameQt::keyEvent(const PlatformKeyboardEvent &keyEvent) const
+{
+    bool result;
+
+    // Check for cases where we are too early for events -- possible unmatched key up
+    // from pressing return in the location bar.
+    Document *doc = document();
+    if (!doc)
+        return false;
+
+    Node *node = doc->focusNode();
+    if (!node) {
+        if (doc->isHTMLDocument())
+            node = doc->body();
+        else
+            node = doc->documentElement();
+
+        if (!node)
+            return false;
+    }
+
+    if (!keyEvent.isKeyUp())
+        prepareForUserAction();
+
+    result = !EventTargetNodeCast(node)->dispatchKeyEvent(keyEvent);
+
+    // FIXME: FrameMac has a keyDown/keyPress hack here which we are not copying.
+    return result;
+}
+
 void FrameQt::receivedData(TransferJob* job, const char* data, int length)
 {
     write(data, length);
--- branches/work/unity/WebKit/WebCore/platform/qt/FrameQt.h #569776:569777
@@ -132,7 +132,7 @@
     virtual void print();
     virtual bool shouldInterruptJavaScript();
 
-    bool keyPress(const PlatformKeyboardEvent&);
+    bool keyEvent(const PlatformKeyboardEvent &keyEvent) const;
 
     virtual void receivedData(TransferJob*, const char*, int);
     virtual void receivedAllData(TransferJob*,PlatformData);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic