[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

eric at webkit.org eric at webkit.org
Thu Feb 4 21:22:57 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 4273f3774fee524a75b2478fbcd3d458c3696ad0
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 21 08:10:46 2010 +0000

    2010-01-21  Luiz Agostini  <luiz.agostini at openbossa.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Custom select popups.
            https://bugs.webkit.org/show_bug.cgi?id=33418
    
            Optimization of the WebCore support to combobox popup delegate.
    
            * platform/qt/PopupMenuQt.cpp:
            (WebCore::PopupMenu::show):
            * platform/qt/QtAbstractWebPopup.cpp:
            (WebCore::QtAbstractWebPopup::QtAbstractWebPopup):
            (WebCore::QtAbstractWebPopup::itemType):
            * platform/qt/QtAbstractWebPopup.h:
            (WebCore::QtAbstractWebPopup::):
            (WebCore::QtAbstractWebPopup::itemText):
            (WebCore::QtAbstractWebPopup::itemToolTip):
            (WebCore::QtAbstractWebPopup::itemIsEnabled):
            (WebCore::QtAbstractWebPopup::itemCount):
            (WebCore::QtAbstractWebPopup::view):
            (WebCore::QtAbstractWebPopup::geometry):
            (WebCore::QtAbstractWebPopup::currentIndex):
            (WebCore::QtAbstractWebPopup::font):
    2010-01-21  Luiz Agostini  <luiz.agostini at openbossa.org>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Custom select popups.
            https://bugs.webkit.org/show_bug.cgi?id=33418
    
            Adjusting QtFallbackWebPopupCombo to the changes in WebCore layer.
    
            * WebCoreSupport/ChromeClientQt.cpp:
            (WebCore::ChromeClientQt::createSelectPopup):
            * WebCoreSupport/ChromeClientQt.h:
            * WebCoreSupport/QtFallbackWebPopup.cpp:
            (WebCore::QtFallbackWebPopupCombo::QtFallbackWebPopupCombo):
            (WebCore::QtFallbackWebPopupCombo::showPopup):
            (WebCore::QtFallbackWebPopupCombo::hidePopup):
            (WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
            (WebCore::QtFallbackWebPopup::~QtFallbackWebPopup):
            (WebCore::QtFallbackWebPopup::show):
            (WebCore::QtFallbackWebPopup::hide):
            (WebCore::QtFallbackWebPopup::populate):
            * WebCoreSupport/QtFallbackWebPopup.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53610 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8a2b227..d51115c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-01-21  Luiz Agostini  <luiz.agostini at openbossa.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Custom select popups.
+        https://bugs.webkit.org/show_bug.cgi?id=33418
+
+        Optimization of the WebCore support to combobox popup delegate.
+
+        * platform/qt/PopupMenuQt.cpp:
+        (WebCore::PopupMenu::show):
+        * platform/qt/QtAbstractWebPopup.cpp:
+        (WebCore::QtAbstractWebPopup::QtAbstractWebPopup):
+        (WebCore::QtAbstractWebPopup::itemType):
+        * platform/qt/QtAbstractWebPopup.h:
+        (WebCore::QtAbstractWebPopup::):
+        (WebCore::QtAbstractWebPopup::itemText):
+        (WebCore::QtAbstractWebPopup::itemToolTip):
+        (WebCore::QtAbstractWebPopup::itemIsEnabled):
+        (WebCore::QtAbstractWebPopup::itemCount):
+        (WebCore::QtAbstractWebPopup::view):
+        (WebCore::QtAbstractWebPopup::geometry):
+        (WebCore::QtAbstractWebPopup::currentIndex):
+        (WebCore::QtAbstractWebPopup::font):
+
 2010-01-20  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/qt/PopupMenuQt.cpp b/WebCore/platform/qt/PopupMenuQt.cpp
index 63e1565..ae4fc20 100644
--- a/WebCore/platform/qt/PopupMenuQt.cpp
+++ b/WebCore/platform/qt/PopupMenuQt.cpp
@@ -46,47 +46,25 @@ PopupMenu::~PopupMenu()
     delete m_popup;
 }
 
-static QList<QtAbstractWebPopup::Item> getItems(PopupMenuClient* client)
-{
-    QList<QtAbstractWebPopup::Item> result;
-
-    int size = client->listSize();
-    for (int i = 0; i < size; ++i) {
-        QtAbstractWebPopup::Item item;
-
-        if (client->itemIsSeparator(i))
-            item.type = QtAbstractWebPopup::Item::Separator;
-        else if (client->itemIsLabel(i))
-            item.type = QtAbstractWebPopup::Item::Group;
-        else
-            item.type = QtAbstractWebPopup::Item::Option;
-
-        item.text = client->itemText(i);
-        item.toolTip = client->itemToolTip(i);
-        item.enabled = client->itemIsEnabled(i);
-        result.append(item);
-    }
-    return result;
-}
-
 void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
 {
     ChromeClientQt* chromeClient = static_cast<ChromeClientQt*>(
         view->frame()->page()->chrome()->client());
     ASSERT(chromeClient);
 
-    if (!m_popup) {
-        m_popup = chromeClient->createPopup();
-        m_popup->m_client = m_popupClient;
-    }
+    if (!m_popup)
+        m_popup = chromeClient->createSelectPopup();
+
+    m_popup->m_client = m_popupClient;
+    m_popup->m_currentIndex = index;
+    m_popup->m_view = chromeClient->platformPageClient()->ownerWidget();
+
+    QRect geometry(rect);
+    geometry.moveTopLeft(view->contentsToWindow(rect.topLeft()));
+    m_popup->m_geometry = geometry;
 
-    m_popup->setParent(chromeClient->platformPageClient()->ownerWidget());
-    m_popup->populate(m_popupClient->menuStyle().font().font(),
-                      getItems(m_popupClient));
+    m_popup->show();
 
-    QRect bounds = rect;
-    bounds.moveTopLeft(view->contentsToWindow(rect.topLeft()));
-    m_popup->show(bounds, index);
 }
 
 void PopupMenu::hide()
diff --git a/WebCore/platform/qt/QtAbstractWebPopup.cpp b/WebCore/platform/qt/QtAbstractWebPopup.cpp
index 75d8fb5..ef7cc2c 100644
--- a/WebCore/platform/qt/QtAbstractWebPopup.cpp
+++ b/WebCore/platform/qt/QtAbstractWebPopup.cpp
@@ -27,6 +27,8 @@ namespace WebCore {
 
 QtAbstractWebPopup::QtAbstractWebPopup()
     : m_client(0)
+    , m_view(0)
+    , m_currentIndex(-1)
 {
 }
 
@@ -46,4 +48,13 @@ void QtAbstractWebPopup::valueChanged(int index)
     m_client->valueChanged(index);
 }
 
+QtAbstractWebPopup::ItemType QtAbstractWebPopup::itemType(int idx) const
+{
+    if (m_client->itemIsSeparator(idx))
+        return Separator;
+    if (m_client->itemIsLabel(idx))
+        return Group;
+    return Option;
+}
+
 } // namespace WebCore
diff --git a/WebCore/platform/qt/QtAbstractWebPopup.h b/WebCore/platform/qt/QtAbstractWebPopup.h
index c890441..1c8f05b 100644
--- a/WebCore/platform/qt/QtAbstractWebPopup.h
+++ b/WebCore/platform/qt/QtAbstractWebPopup.h
@@ -20,38 +20,47 @@
 #ifndef QtAbstractWebPopup_h
 #define QtAbstractWebPopup_h
 
+#include "PopupMenuClient.h"
+
 #include <QFont>
 #include <QList>
 #include <QRect>
+#include <QWidget>
 
 namespace WebCore {
 
-class PopupMenuClient;
 
 class QtAbstractWebPopup {
 public:
-    struct Item {
-        enum { Option, Group, Separator } type;
-        QString text;
-        QString toolTip;
-        bool enabled;
-    };
+    enum ItemType { Option, Group, Separator };
+
+    ItemType itemType(int) const;
+    QString itemText(int idx) const { return m_client->itemText(idx); }
+    QString itemToolTip(int idx) const { return m_client->itemToolTip(idx); }
+    bool itemIsEnabled(int idx) const { return m_client->itemIsEnabled(idx); }
+    int itemCount() const { return m_client->listSize(); }
+
+    QWidget* view() { return m_view; }
+    QRect geometry() const { return m_geometry; }
+    int currentIndex() const { return m_currentIndex; }
 
     QtAbstractWebPopup();
     virtual ~QtAbstractWebPopup();
 
-    virtual void show(const QRect& geometry, int selectedIndex) = 0;
+    virtual void show() = 0;
     virtual void hide() = 0;
-    virtual void populate(const QFont& font, const QList<Item>& items) = 0;
-    virtual void setParent(QWidget* parent) = 0;
 
-protected:
     void popupDidHide(bool acceptSuggestions);
     void valueChanged(int index);
 
+    QFont font() { return m_client->menuStyle().font().font(); }
+
 private:
     friend class PopupMenu;
     PopupMenuClient* m_client;
+    QWidget* m_view;
+    int m_currentIndex;
+    QRect m_geometry;
 };
 
 }
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index b76dcb9..c23c018 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,26 @@
+2010-01-21  Luiz Agostini  <luiz.agostini at openbossa.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Custom select popups.
+        https://bugs.webkit.org/show_bug.cgi?id=33418
+
+        Adjusting QtFallbackWebPopupCombo to the changes in WebCore layer.
+
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::createSelectPopup):
+        * WebCoreSupport/ChromeClientQt.h:
+        * WebCoreSupport/QtFallbackWebPopup.cpp:
+        (WebCore::QtFallbackWebPopupCombo::QtFallbackWebPopupCombo):
+        (WebCore::QtFallbackWebPopupCombo::showPopup):
+        (WebCore::QtFallbackWebPopupCombo::hidePopup):
+        (WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
+        (WebCore::QtFallbackWebPopup::~QtFallbackWebPopup):
+        (WebCore::QtFallbackWebPopup::show):
+        (WebCore::QtFallbackWebPopup::hide):
+        (WebCore::QtFallbackWebPopup::populate):
+        * WebCoreSupport/QtFallbackWebPopup.h:
+
 2010-01-19  Steve Block  <steveblock at google.com>
 
         Reviewed by Adam Barth.
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index f62bc86..6345539 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -466,7 +466,7 @@ void ChromeClientQt::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
     notImplemented();
 }
 
-QtAbstractWebPopup* ChromeClientQt::createPopup()
+QtAbstractWebPopup* ChromeClientQt::createSelectPopup()
 {
     return new QtFallbackWebPopup;
 }
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index 106d4cc..7077501 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -135,7 +135,7 @@ namespace WebCore {
 
         virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
 
-        QtAbstractWebPopup* createPopup();
+        QtAbstractWebPopup* createSelectPopup();
 
         QWebPage* m_webPage;
         WebCore::KURL lastHoverURL;
diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp
index 344d58a..be98e53 100644
--- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp
+++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp
@@ -31,87 +31,98 @@
 
 namespace WebCore {
 
+QtFallbackWebPopupCombo::QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup)
+    : m_ownerPopup(ownerPopup)
+{
+}
+
+void QtFallbackWebPopupCombo::showPopup()
+{
+    QComboBox::showPopup();
+    m_ownerPopup.m_popupVisible = true;
+}
+
+void QtFallbackWebPopupCombo::hidePopup()
+{
+    QWidget* activeFocus = QApplication::focusWidget();
+    if (activeFocus && activeFocus == QComboBox::view()
+        && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
+        QInputContext* qic = activeFocus->inputContext();
+        if (qic) {
+            qic->reset();
+            qic->setFocusWidget(0);
+        }
+    }
+
+    QComboBox::hidePopup();
+    if (!m_ownerPopup.m_popupVisible)
+        return;
+
+    m_ownerPopup.m_popupVisible = false;
+    m_ownerPopup.popupDidHide(true);
+}
+
 // QtFallbackWebPopup
 
 QtFallbackWebPopup::QtFallbackWebPopup()
     : QtAbstractWebPopup()
     , m_popupVisible(false)
+    , m_combo(new QtFallbackWebPopupCombo(*this))
 {
-    connect(this, SIGNAL(activated(int)),
+    connect(m_combo, SIGNAL(activated(int)),
             SLOT(activeChanged(int)), Qt::QueuedConnection);
 }
 
-
-void QtFallbackWebPopup::show(const QRect& geometry, int selectedIndex)
+QtFallbackWebPopup::~QtFallbackWebPopup()
 {
-    setCurrentIndex(selectedIndex);
-
-    /*
-    QWidget* parent = 0;
-    if (client()->hostWindow() && client()->hostWindow()->platformPageClient())
-       parent = client()->hostWindow()->platformPageClient()->ownerWidget();
+    delete m_combo;
+}
 
-    setParent(parent);
-    */
+void QtFallbackWebPopup::show()
+{
+    populate();
+    m_combo->setParent(view());
+    m_combo->setCurrentIndex(currentIndex());
 
-    setGeometry(QRect(geometry.left(), geometry.top(), geometry.width(), sizeHint().height()));
+    QRect rect = geometry();
+    m_combo->setGeometry(QRect(rect.left(), rect.top(),
+                               rect.width(), m_combo->sizeHint().height()));
 
     QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton,
                       Qt::LeftButton, Qt::NoModifier);
-    QCoreApplication::sendEvent(this, &event);
+    QCoreApplication::sendEvent(m_combo, &event);
 }
 
-void QtFallbackWebPopup::populate(const QFont& font, const QList<Item>& items)
+void QtFallbackWebPopup::hide()
 {
-    clear();
+    m_combo->hidePopup();
+}
+
+void QtFallbackWebPopup::populate()
+{
+    m_combo->clear();
 
-    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(QComboBox::model());
+    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_combo->model());
     Q_ASSERT(model);
 
-    setFont(font);
-    for (int i = 0; i < items.size(); ++i) {
-        switch (items[i].type) {
-        case QtAbstractWebPopup::Item::Separator:
-            insertSeparator(i);
+    m_combo->setFont(font());
+    for (int i = 0; i < itemCount(); ++i) {
+        switch (itemType(i)) {
+        case Separator:
+            m_combo->insertSeparator(i);
             break;
-        case QtAbstractWebPopup::Item::Group:
-            insertItem(i, items[i].text);
+        case Group:
+            m_combo->insertItem(i, itemText(i));
             model->item(i)->setEnabled(false);
             break;
-        case QtAbstractWebPopup::Item::Option:
-            insertItem(i, items[i].text);
-            model->item(i)->setEnabled(items[i].enabled);
+        case Option:
+            m_combo->insertItem(i, itemText(i));
+            model->item(i)->setEnabled(itemIsEnabled(i));
             break;
         }
     }
 }
 
-void QtFallbackWebPopup::showPopup()
-{
-    QComboBox::showPopup();
-    m_popupVisible = true;
-}
-
-void QtFallbackWebPopup::hidePopup()
-{
-    QWidget* activeFocus = QApplication::focusWidget();
-    if (activeFocus && activeFocus == view()
-        && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
-        QInputContext* qic = activeFocus->inputContext();
-        if (qic) {
-            qic->reset();
-            qic->setFocusWidget(0);
-        }
-    }
-
-    QComboBox::hidePopup();
-    if (!m_popupVisible)
-        return;
-
-    m_popupVisible = false;
-    popupDidHide(true);
-}
-
 void QtFallbackWebPopup::activeChanged(int index)
 {
     if (index < 0)
@@ -120,9 +131,4 @@ void QtFallbackWebPopup::activeChanged(int index)
     valueChanged(index);
 }
 
-void QtFallbackWebPopup::setParent(QWidget* parent)
-{
-    QComboBox::setParent(parent);
-}
-
 }
diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h
index 5affe0a..8fbec6f 100644
--- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h
+++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h
@@ -25,25 +25,36 @@
 
 namespace WebCore {
 
-class QtFallbackWebPopup : private QComboBox, public QtAbstractWebPopup {
+class QtFallbackWebPopupCombo;
+
+class QtFallbackWebPopup : public QObject, public QtAbstractWebPopup {
     Q_OBJECT
 public:
     QtFallbackWebPopup();
+    ~QtFallbackWebPopup();
 
-    virtual void show(const QRect& geometry, int selectedIndex);
-    virtual void hide() { hidePopup(); }
-    virtual void populate(const QFont& font, const QList<Item>& items);
-    virtual void setParent(QWidget* parent);
+    virtual void show();
+    virtual void hide();
 
 private slots:
     void activeChanged(int);
 
 private:
+    friend class QtFallbackWebPopupCombo;
     bool m_popupVisible;
+    QtFallbackWebPopupCombo* m_combo;
 
+    void populate();
+};
 
+class QtFallbackWebPopupCombo : public QComboBox {
+public:
+    QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup);
     virtual void showPopup();
     virtual void hidePopup();
+
+private:
+    QtFallbackWebPopup& m_ownerPopup;
 };
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list