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

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 16:28:06 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7956a807ed84976ada42ef3bda38f95d531ca09c
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 24 09:34:56 2010 +0000

    2010-11-24  Jan Erik Hanssen  <jhanssen at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Html autofocus not working with QGraphicsWebView
            https://bugs.webkit.org/show_bug.cgi?id=43169
    
            QGraphicsScene does not propagate Qt::ActivateWindowFocusReason focus
            events when there are no active items.
    
            * Api/qgraphicswebview.cpp:
            (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
            (QGraphicsWebView::QGraphicsWebView):
            (QGraphicsWebView::eventFilter):
            (QGraphicsWebView::itemChange):
            * Api/qgraphicswebview.h:
            * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
            (FocusPage::FocusPage):
            (FocusPage::event):
            (FocusPage::gotFocus):
            (tst_QGraphicsWebView::receivesFocusInOnShow):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72650 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp
index c8438f3..f94ae0e 100644
--- a/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/WebKit/qt/Api/qgraphicswebview.cpp
@@ -53,7 +53,8 @@ public:
     QGraphicsWebViewPrivate(QGraphicsWebView* parent)
         : q(parent)
         , page(0)
-        , resizesToContents(false) {}
+        , resizesToContents(false)
+        , currentScene(0) {}
 
     virtual ~QGraphicsWebViewPrivate();
 
@@ -75,6 +76,7 @@ public:
     QGraphicsWebView* q;
     QWebPage* page;
     bool resizesToContents;
+    QGraphicsScene* currentScene;
 
     QGraphicsItemOverlay* overlay() const
     {
@@ -252,6 +254,11 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent)
 #if ENABLE(TILED_BACKING_STORE)
     QObject::connect(this, SIGNAL(scaleChanged()), this, SLOT(_q_scaleChanged()));
 #endif
+
+    if (scene()) {
+        d->currentScene = scene();
+        d->currentScene->installEventFilter(this);
+    }
 }
 
 /*!
@@ -308,6 +315,20 @@ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem*
 
 /*! \reimp
 */
+bool QGraphicsWebView::eventFilter(QObject* object, QEvent* event)
+{
+    if (object == d->currentScene
+        && (event->type() == QEvent::FocusIn
+            || event->type() == QEvent::FocusOut)) {
+        QFocusEvent* focusEvent = static_cast<QFocusEvent*>(event);
+        if (focusEvent->reason() == Qt::ActiveWindowFocusReason)
+            d->page->event(event);
+    }
+    return false;
+}
+
+/*! \reimp
+*/
 bool QGraphicsWebView::sceneEvent(QEvent* event)
 {
     // Re-implemented in order to allows fixing event-related bugs in patch releases.
@@ -342,6 +363,14 @@ QVariant QGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant&
             QApplication::sendEvent(this, &event);
             return value;
         }
+    case ItemSceneHasChanged: {
+            QGraphicsScene* newScene = qVariantValue<QGraphicsScene*>(value);
+            if (d->currentScene)
+                d->currentScene->removeEventFilter(this);
+            d->currentScene = newScene;
+            if (d->currentScene)
+                d->currentScene->installEventFilter(this);
+        }
     default:
         break;
     }
diff --git a/WebKit/qt/Api/qgraphicswebview.h b/WebKit/qt/Api/qgraphicswebview.h
index 8620ac5..a484e9e 100644
--- a/WebKit/qt/Api/qgraphicswebview.h
+++ b/WebKit/qt/Api/qgraphicswebview.h
@@ -140,6 +140,8 @@ protected:
 
     virtual bool sceneEvent(QEvent*);
 
+    virtual bool eventFilter(QObject*, QEvent*);
+
 private:
     Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 22789c4..2fe238c 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,25 @@
+2010-11-24  Jan Erik Hanssen  <jhanssen at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Html autofocus not working with QGraphicsWebView
+        https://bugs.webkit.org/show_bug.cgi?id=43169
+
+        QGraphicsScene does not propagate Qt::ActivateWindowFocusReason focus
+        events when there are no active items.
+
+        * Api/qgraphicswebview.cpp:
+        (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
+        (QGraphicsWebView::QGraphicsWebView):
+        (QGraphicsWebView::eventFilter):
+        (QGraphicsWebView::itemChange):
+        * Api/qgraphicswebview.h:
+        * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+        (FocusPage::FocusPage):
+        (FocusPage::event):
+        (FocusPage::gotFocus):
+        (tst_QGraphicsWebView::receivesFocusInOnShow):
+
 2010-11-23  Kenneth Rohde Christiansen  <kenneth at webkit.org>
 
         Reviewed by Andreas Kling.
diff --git a/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
index 09a21e1..284efd2 100644
--- a/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
+++ b/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
@@ -36,6 +36,7 @@ private slots:
     void focusInputTypes();
     void crashOnSetScaleBeforeSetUrl();
     void widgetsRenderingThroughCache();
+    void receivesFocusInOnShow();
 };
 
 void tst_QGraphicsWebView::qgraphicswebview()
@@ -259,6 +260,58 @@ void tst_QGraphicsWebView::focusInputTypes()
     delete view;
 }
 
+class FocusPage : public QWebPage {
+public:
+    FocusPage(QObject* parent = 0);
+
+    bool gotFocus() const;
+
+protected:
+    bool event(QEvent* e);
+
+private:
+    bool m_focus;
+};
+
+FocusPage::FocusPage(QObject *parent)
+    : QWebPage(parent), m_focus(false)
+{
+}
+
+bool FocusPage::event(QEvent *e)
+{
+    if (e->type() == QEvent::FocusIn)
+        m_focus = true;
+    return QWebPage::event(e);
+}
+
+bool FocusPage::gotFocus() const
+{
+    return m_focus;
+}
+
+void tst_QGraphicsWebView::receivesFocusInOnShow()
+{
+    QGraphicsWebView webView;
+    webView.setHtml("<body><input type=text autofocus=autofocus></input></body>");
+    FocusPage page;
+    webView.setPage(&page);
+
+    for (int i = 0; i < 3; ++i) {
+        QGraphicsView view;
+        QGraphicsScene* scene = new QGraphicsScene(&view);
+        view.setScene(scene);
+        scene->addItem(&webView);
+        view.setGeometry(QRect(0, 0, 500, 500));
+
+        view.show();
+        QTest::qWaitForWindowShown(&view);
+
+        QVERIFY(page.gotFocus());
+
+        scene->removeItem(&webView);
+    }
+}
 
 
 QTEST_MAIN(tst_QGraphicsWebView)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list