Changeset 72202 in webkit


Ignore:
Timestamp:
Nov 17, 2010 5:50:16 AM (13 years ago)
Author:
benjamin.poulain@nokia.com
Message:

[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:
Location:
trunk/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r72193 r72202  
     12010-11-17  Benjamin Poulain  <benjamin.poulain@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] [WK2] The focus switching does not seems to work with QGraphicsWKView
     6        https://bugs.webkit.org/show_bug.cgi?id=49545
     7
     8        Implement focus switching with Tab. This is now done asynchronously,
     9        waiting for webkit to call takeFocus() and switching the widget.
     10
     11        Since the focus can change between the Tab press and the callback,
     12        QGraphicsWKView::focusNextPrevChildCallback() make sure the view still has
     13        focus before passing it to the next widget.
     14
     15        * UIProcess/API/qt/qgraphicswkview.cpp:
     16        (QGraphicsWKView::QGraphicsWKView):
     17        (QGraphicsWKView::focusNextPrevChildCallback):
     18        (QGraphicsWKView::focusNextPrevChild):
     19        * UIProcess/API/qt/qgraphicswkview.h:
     20        * UIProcess/API/qt/qwkpage.cpp:
     21        (QWKPagePrivate::takeFocus):
     22        * UIProcess/API/qt/qwkpage.h:
     23        * UIProcess/API/qt/qwkpage_p.h:
     24
    1252010-11-17  Andreas Kling  <kling@webkit.org>
    226
  • trunk/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp

    r72016 r72202  
    8989    connect(d->page, SIGNAL(urlChanged(const QUrl&)), this, SIGNAL(urlChanged(const QUrl&)));
    9090    connect(d->page, SIGNAL(cursorChanged(const QCursor&)), this, SLOT(updateCursor(const QCursor&)));
     91    connect(d->page, SIGNAL(focusNextPrevChild(bool)), this, SLOT(focusNextPrevChildCallback(bool)));
    9192}
    9293
     
    167168{
    168169    setCursor(cursor);
     170}
     171
     172class FriendlyWidget : public QWidget
     173{
     174public:
     175    bool focusNextPrevChild(bool next);
     176};
     177
     178void QGraphicsWKView::focusNextPrevChildCallback(bool next)
     179{
     180    if (hasFocus()) {
     181        // find the view which has the focus:
     182        QList<QGraphicsView*> views = scene()->views();
     183        const int viewCount = views.count();
     184        QGraphicsView* focusedView = 0;
     185        for (int i = 0; i < viewCount; ++i) {
     186            if (views[i]->hasFocus()) {
     187                focusedView = views[i];
     188                break;
     189            }
     190        }
     191
     192        if (focusedView) {
     193            QWidget* window = focusedView->window();
     194            FriendlyWidget* friendlyWindow = static_cast<FriendlyWidget*>(window);
     195            friendlyWindow->focusNextPrevChild(next);
     196        }
     197    }
     198}
     199
     200/*! \reimp
     201*/
     202bool QGraphicsWKView::focusNextPrevChild(bool next)
     203{
     204    QKeyEvent ev(QEvent::KeyPress, Qt::Key_Tab, Qt::KeyboardModifiers(next ? Qt::NoModifier : Qt::ShiftModifier));
     205    page()->d->keyPressEvent(&ev);
     206    return true;
    169207}
    170208
  • trunk/WebKit2/UIProcess/API/qt/qgraphicswkview.h

    r72016 r72202  
    8282
    8383    Q_SLOT void updateCursor(const QCursor&);
     84    Q_SLOT void focusNextPrevChildCallback(bool next);
    8485
     86    virtual bool focusNextPrevChild(bool next);
    8587    virtual void focusInEvent(QFocusEvent*);
    8688    virtual void focusOutEvent(QFocusEvent*);
  • trunk/WebKit2/UIProcess/API/qt/qwkpage.cpp

    r72100 r72202  
    9797    viewportArguments = args;
    9898    emit q->viewportChangeRequested();
     99}
     100
     101void QWKPagePrivate::takeFocus(bool direction)
     102{
     103    emit q->focusNextPrevChild(direction);
    99104}
    100105
  • trunk/WebKit2/UIProcess/API/qt/qwkpage.h

    r72100 r72202  
    119119    Q_SIGNAL void windowCloseRequested();
    120120    Q_SIGNAL void zoomableAreaFound(const QRect&);
     121    Q_SIGNAL void focusNextPrevChild(bool);
    121122
    122123protected:
  • trunk/WebKit2/UIProcess/API/qt/qwkpage_p.h

    r72100 r72202  
    5656    virtual void setCursor(const WebCore::Cursor&);
    5757    virtual void setViewportArguments(const WebCore::ViewportArguments&);
    58     virtual void takeFocus(bool direction) { }
     58    virtual void takeFocus(bool direction);
    5959    virtual void toolTipChanged(const WTF::String&, const WTF::String&);
    6060    virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
Note: See TracChangeset for help on using the changeset viewer.