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

benjamin.poulain at nokia.com benjamin.poulain at nokia.com
Wed Dec 22 15:58:48 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4af22c6a3a34ea27378b685287d5373c0f5bd0a8
Author: benjamin.poulain at nokia.com <benjamin.poulain at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 17 13:50:16 2010 +0000

    [Qt] [WK2] The focus switching does not seems to work with QGraphicsWKView
    https://bugs.webkit.org/show_bug.cgi?id=49545
    
    Reviewed by Kenneth Rohde Christiansen.
    
    Implement focus switching with Tab. This is now done asynchronously,
    waiting for webkit to call takeFocus() and switching the widget.
    
    Since the focus can change between the Tab press and the callback,
    QGraphicsWKView::focusNextPrevChildCallback() make sure the view still has
    focus before passing it to the next widget.
    
    * UIProcess/API/qt/qgraphicswkview.cpp:
    (QGraphicsWKView::QGraphicsWKView):
    (QGraphicsWKView::focusNextPrevChildCallback):
    (QGraphicsWKView::focusNextPrevChild):
    * UIProcess/API/qt/qgraphicswkview.h:
    * UIProcess/API/qt/qwkpage.cpp:
    (QWKPagePrivate::takeFocus):
    * UIProcess/API/qt/qwkpage.h:
    * UIProcess/API/qt/qwkpage_p.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72202 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 56f874d..5675d7a 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,27 @@
+2010-11-17  Benjamin Poulain  <benjamin.poulain at nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] [WK2] The focus switching does not seems to work with QGraphicsWKView
+        https://bugs.webkit.org/show_bug.cgi?id=49545
+
+        Implement focus switching with Tab. This is now done asynchronously,
+        waiting for webkit to call takeFocus() and switching the widget.
+
+        Since the focus can change between the Tab press and the callback,
+        QGraphicsWKView::focusNextPrevChildCallback() make sure the view still has
+        focus before passing it to the next widget.
+
+        * UIProcess/API/qt/qgraphicswkview.cpp:
+        (QGraphicsWKView::QGraphicsWKView):
+        (QGraphicsWKView::focusNextPrevChildCallback):
+        (QGraphicsWKView::focusNextPrevChild):
+        * UIProcess/API/qt/qgraphicswkview.h:
+        * UIProcess/API/qt/qwkpage.cpp:
+        (QWKPagePrivate::takeFocus):
+        * UIProcess/API/qt/qwkpage.h:
+        * UIProcess/API/qt/qwkpage_p.h:
+
 2010-11-17  Andreas Kling  <kling at webkit.org>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
index 33f4194..08bdbbb 100644
--- a/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
+++ b/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
@@ -88,6 +88,7 @@ QGraphicsWKView::QGraphicsWKView(WKPageNamespaceRef pageNamespaceRef, BackingSto
     connect(d->page, SIGNAL(initialLayoutCompleted()), this, SIGNAL(initialLayoutCompleted()));
     connect(d->page, SIGNAL(urlChanged(const QUrl&)), this, SIGNAL(urlChanged(const QUrl&)));
     connect(d->page, SIGNAL(cursorChanged(const QCursor&)), this, SLOT(updateCursor(const QCursor&)));
+    connect(d->page, SIGNAL(focusNextPrevChild(bool)), this, SLOT(focusNextPrevChildCallback(bool)));
 }
 
 QGraphicsWKView::~QGraphicsWKView()
@@ -168,6 +169,43 @@ void QGraphicsWKView::updateCursor(const QCursor& cursor)
     setCursor(cursor);
 }
 
+class FriendlyWidget : public QWidget
+{
+public:
+    bool focusNextPrevChild(bool next);
+};
+
+void QGraphicsWKView::focusNextPrevChildCallback(bool next)
+{
+    if (hasFocus()) {
+        // find the view which has the focus:
+        QList<QGraphicsView*> views = scene()->views();
+        const int viewCount = views.count();
+        QGraphicsView* focusedView = 0;
+        for (int i = 0; i < viewCount; ++i) {
+            if (views[i]->hasFocus()) {
+                focusedView = views[i];
+                break;
+            }
+        }
+
+        if (focusedView) {
+            QWidget* window = focusedView->window();
+            FriendlyWidget* friendlyWindow = static_cast<FriendlyWidget*>(window);
+            friendlyWindow->focusNextPrevChild(next);
+        }
+    }
+}
+
+/*! \reimp
+*/
+bool QGraphicsWKView::focusNextPrevChild(bool next)
+{
+    QKeyEvent ev(QEvent::KeyPress, Qt::Key_Tab, Qt::KeyboardModifiers(next ? Qt::NoModifier : Qt::ShiftModifier));
+    page()->d->keyPressEvent(&ev);
+    return true;
+}
+
 /*! \reimp
 */
 QVariant QGraphicsWKView::itemChange(GraphicsItemChange change, const QVariant& value)
diff --git a/WebKit2/UIProcess/API/qt/qgraphicswkview.h b/WebKit2/UIProcess/API/qt/qgraphicswkview.h
index 6281018..6c3c157 100644
--- a/WebKit2/UIProcess/API/qt/qgraphicswkview.h
+++ b/WebKit2/UIProcess/API/qt/qgraphicswkview.h
@@ -81,7 +81,9 @@ protected:
     virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*);
 
     Q_SLOT void updateCursor(const QCursor&);
+    Q_SLOT void focusNextPrevChildCallback(bool next);
 
+    virtual bool focusNextPrevChild(bool next);
     virtual void focusInEvent(QFocusEvent*);
     virtual void focusOutEvent(QFocusEvent*);
 
diff --git a/WebKit2/UIProcess/API/qt/qwkpage.cpp b/WebKit2/UIProcess/API/qt/qwkpage.cpp
index 6dff153..2eb507a 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage.cpp
+++ b/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -98,6 +98,11 @@ void QWKPagePrivate::setViewportArguments(const ViewportArguments& args)
     emit q->viewportChangeRequested();
 }
 
+void QWKPagePrivate::takeFocus(bool direction)
+{
+    emit q->focusNextPrevChild(direction);
+}
+
 void QWKPagePrivate::pageDidRequestScroll(const IntSize& delta)
 {
     emit q->scrollRequested(delta.width(), delta.height());
diff --git a/WebKit2/UIProcess/API/qt/qwkpage.h b/WebKit2/UIProcess/API/qt/qwkpage.h
index 882b38f..8f63bbc 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage.h
+++ b/WebKit2/UIProcess/API/qt/qwkpage.h
@@ -118,6 +118,7 @@ public:
     Q_SIGNAL void viewportChangeRequested();
     Q_SIGNAL void windowCloseRequested();
     Q_SIGNAL void zoomableAreaFound(const QRect&);
+    Q_SIGNAL void focusNextPrevChild(bool);
 
 protected:
     void timerEvent(QTimerEvent*);
diff --git a/WebKit2/UIProcess/API/qt/qwkpage_p.h b/WebKit2/UIProcess/API/qt/qwkpage_p.h
index 496f7c3..55ff764 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage_p.h
+++ b/WebKit2/UIProcess/API/qt/qwkpage_p.h
@@ -55,7 +55,7 @@ public:
     virtual void didFindZoomableArea(const WebCore::IntRect&);
     virtual void setCursor(const WebCore::Cursor&);
     virtual void setViewportArguments(const WebCore::ViewportArguments&);
-    virtual void takeFocus(bool direction) { }
+    virtual void takeFocus(bool direction);
     virtual void toolTipChanged(const WTF::String&, const WTF::String&);
     virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
     virtual void clearAllEditCommands();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list