Changeset 53005 in webkit


Ignore:
Timestamp:
Jan 8, 2010 1:48:02 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-08 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Delegation client
https://bugs.webkit.org/show_bug.cgi?id=32826

Factory related code removed from QtAbstractWebPopup. Popups are now created
by ChromeClientQt.
Popup content information struct added to class QtAbstractWebPopup.
PopupMenuClient is now hidden from higher layers.
QtAbstractWebPopup now receives content information and font as parameters
of method populate.
QtFallbackWebPopup moved to WebKit/qt/WebCoreSupport.

  • WebCore.pro:
  • platform/qt/PopupMenuQt.cpp: (WebCore::PopupMenu::PopupMenu): (WebCore::getItems): (WebCore::PopupMenu::show):
  • platform/qt/QtAbstractWebPopup.cpp: (WebCore::QtAbstractWebPopup::QtAbstractWebPopup): (WebCore::QtAbstractWebPopup::popupDidHide): (WebCore::QtAbstractWebPopup::valueChanged):
  • platform/qt/QtAbstractWebPopup.h: (WebCore::QtAbstractWebPopup::Item::):
  • platform/qt/QtFallbackWebPopup.cpp: Removed.
  • platform/qt/QtFallbackWebPopup.h: Removed.

2010-01-08 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Delegation client
https://bugs.webkit.org/show_bug.cgi?id=32826

Added method createPopup to ChromeClientQt used to create popups.
QtFallbackWebPopup moved from WebCore/platform/qt to
WebKit/qt/WebCoreSupport.

  • WebCoreSupport/ChromeClientQt.cpp: (WebCore::ChromeClientQt::createPopup):
  • WebCoreSupport/ChromeClientQt.h:
  • WebCoreSupport/QtFallbackWebPopup.cpp: Added. (WebCore::QtFallbackWebPopup::QtFallbackWebPopup): (WebCore::QtFallbackWebPopup::show): (WebCore::QtFallbackWebPopup::populate): (WebCore::QtFallbackWebPopup::showPopup): (WebCore::QtFallbackWebPopup::hidePopup): (WebCore::QtFallbackWebPopup::activeChanged): (WebCore::QtFallbackWebPopup::setParent):
  • WebCoreSupport/QtFallbackWebPopup.h: Added. (WebCore::QtFallbackWebPopup::hide):
Location:
trunk
Files:
8 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53004 r53005  
     12010-01-08  Luiz Agostini  <luiz.agostini@openbossa.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Delegation client
     6        https://bugs.webkit.org/show_bug.cgi?id=32826
     7
     8        Factory related code removed from QtAbstractWebPopup. Popups are now created
     9        by ChromeClientQt.
     10        Popup content information struct added to class QtAbstractWebPopup.
     11        PopupMenuClient is now hidden from higher layers.
     12        QtAbstractWebPopup now receives content information and font as parameters
     13        of method populate.
     14        QtFallbackWebPopup moved to WebKit/qt/WebCoreSupport.
     15
     16        * WebCore.pro:
     17        * platform/qt/PopupMenuQt.cpp:
     18        (WebCore::PopupMenu::PopupMenu):
     19        (WebCore::getItems):
     20        (WebCore::PopupMenu::show):
     21        * platform/qt/QtAbstractWebPopup.cpp:
     22        (WebCore::QtAbstractWebPopup::QtAbstractWebPopup):
     23        (WebCore::QtAbstractWebPopup::popupDidHide):
     24        (WebCore::QtAbstractWebPopup::valueChanged):
     25        * platform/qt/QtAbstractWebPopup.h:
     26        (WebCore::QtAbstractWebPopup::Item::):
     27        * platform/qt/QtFallbackWebPopup.cpp: Removed.
     28        * platform/qt/QtFallbackWebPopup.h: Removed.
     29
    1302010-01-08  Yuzo Fujishima  <yuzo@google.com>
    231
  • trunk/WebCore/WebCore.pro

    r52972 r53005  
    19841984    platform/qt/QWebPageClient.h \
    19851985    platform/qt/QtAbstractWebPopup.h \
    1986     platform/qt/QtFallbackWebPopup.h \
    19871986    platform/qt/RenderThemeQt.h \
    19881987    platform/qt/ScrollbarThemeQt.h \
     
    23862385    xml/XSLTUnicodeSort.h \
    23872386    $$PWD/../WebKit/qt/Api/qwebplugindatabase_p.h \
     2387    $$PWD/../WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h \
    23882388    $$PWD/../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h \
    23892389    $$PWD/platform/network/qt/DnsPrefetchHelper.h
     
    24472447    platform/qt/PopupMenuQt.cpp \
    24482448    platform/qt/QtAbstractWebPopup.cpp \
    2449     platform/qt/QtFallbackWebPopup.cpp \
    24502449    platform/qt/RenderThemeQt.cpp \
    24512450    platform/qt/ScrollbarQt.cpp \
     
    24642463    platform/qt/WidgetQt.cpp \
    24652464    plugins/qt/PluginDataQt.cpp \
     2465    ../WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp \
    24662466    ../WebKit/qt/WebCoreSupport/ChromeClientQt.cpp \
    24672467    ../WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp \
  • trunk/WebCore/platform/qt/PopupMenuQt.cpp

    r52223 r53005  
    22 * This file is part of the popup menu implementation for <select> elements in WebCore.
    33 *
    4  * Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
     4 * Copyright (C) 2008, 2009, 2010 Nokia Corporation and/or its subsidiary(-ies)
    55 * Copyright (C) 2006 Apple Computer, Inc.
    66 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
     
    2727#include "PopupMenu.h"
    2828
     29#include "Chrome.h"
     30#include "ChromeClientQt.h"
    2931#include "FrameView.h"
    3032#include "PopupMenuClient.h"
     33#include "QWebPageClient.h"
    3134#include "QtAbstractWebPopup.h"
    32 #include "QtFallbackWebPopup.h"
    3335
    3436namespace WebCore {
     
    3638PopupMenu::PopupMenu(PopupMenuClient* client)
    3739    : m_popupClient(client)
     40    , m_popup(0)
    3841{
    39     m_popup = QtAbstractWebPopup::create(client);
    4042}
    4143
     
    4547}
    4648
    47 void PopupMenu::show(const IntRect& r, FrameView* v, int index)
     49static QList<QtAbstractWebPopup::Item> getItems(PopupMenuClient* client)
    4850{
    49     QRect rect = r;
    50     rect.moveTopLeft(v->contentsToWindow(r.topLeft()));
    51     m_popup->show(rect, index);
     51    QList<QtAbstractWebPopup::Item> result;
     52
     53    int size = client->listSize();
     54    for (int i = 0; i < size; ++i) {
     55        QtAbstractWebPopup::Item item;
     56
     57        if (client->itemIsSeparator(i))
     58            item.type = QtAbstractWebPopup::Item::Separator;
     59        else if (client->itemIsLabel(i))
     60            item.type = QtAbstractWebPopup::Item::Group;
     61        else
     62            item.type = QtAbstractWebPopup::Item::Option;
     63
     64        item.text = client->itemText(i);
     65        item.toolTip = client->itemToolTip(i);
     66        item.enabled = client->itemIsEnabled(i);
     67        result.append(item);
     68    }
     69    return result;
     70}
     71
     72void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
     73{
     74    ChromeClientQt* chromeClient = static_cast<ChromeClientQt*>(
     75        view->frame()->page()->chrome()->client());
     76    ASSERT(chromeClient);
     77
     78    if (!m_popup) {
     79        m_popup = chromeClient->createPopup();
     80        m_popup->m_client = m_popupClient;
     81    }
     82
     83    m_popup->setParent(chromeClient->platformPageClient()->ownerWidget());
     84    m_popup->populate(m_popupClient->menuStyle().font().font(),
     85                      getItems(m_popupClient));
     86
     87    QRect bounds = rect;
     88    bounds.moveTopLeft(view->contentsToWindow(rect.topLeft()));
     89    m_popup->show(bounds, index);
    5290}
    5391
  • trunk/WebCore/platform/qt/QtAbstractWebPopup.cpp

    r52223 r53005  
    2222
    2323#include "PopupMenuClient.h"
    24 #include "QtFallbackWebPopup.h"
    2524
    2625
    2726namespace WebCore {
    2827
    29 QtAbstractWebPopupFactory* QtAbstractWebPopup::m_factory = 0;
    30 
    31 QtAbstractWebPopup::QtAbstractWebPopup(PopupMenuClient* client)
    32     : m_client(client)
     28QtAbstractWebPopup::QtAbstractWebPopup()
     29    : m_client(0)
    3330{
    34     Q_ASSERT(m_client);
    3531}
    3632
     
    3935}
    4036
    41 PopupMenuClient* QtAbstractWebPopup::client()
     37void QtAbstractWebPopup::popupDidHide(bool acceptSuggestions)
    4238{
    43     return m_client;
     39    Q_ASSERT(m_client);
     40    m_client->popupDidHide(acceptSuggestions);
    4441}
    4542
    46 void QtAbstractWebPopup::setFactory(QtAbstractWebPopupFactory* factory)
     43void QtAbstractWebPopup::valueChanged(int index)
    4744{
    48     m_factory = factory;
    49 }
    50 
    51 QtAbstractWebPopup* QtAbstractWebPopup::create(PopupMenuClient* client)
    52 {
    53     return m_factory ? m_factory->create(client) : new QtFallbackWebPopup(client);
     45    Q_ASSERT(m_client);
     46    m_client->valueChanged(index);
    5447}
    5548
  • trunk/WebCore/platform/qt/QtAbstractWebPopup.h

    r52223 r53005  
    2121#define QtAbstractWebPopup_h
    2222
     23#include <QFont>
     24#include <QList>
    2325#include <QRect>
    2426
    2527namespace WebCore {
    2628
    27 class QtAbstractWebPopup;
    2829class PopupMenuClient;
    29 
    30 class QtAbstractWebPopupFactory {
    31 public:
    32     virtual QtAbstractWebPopup* create(PopupMenuClient* client) = 0;
    33 };
    3430
    3531class QtAbstractWebPopup {
    3632public:
    37     QtAbstractWebPopup(PopupMenuClient* client);
     33    struct Item {
     34        enum { Option, Group, Separator } type;
     35        QString text;
     36        QString toolTip;
     37        bool enabled;
     38    };
     39
     40    QtAbstractWebPopup();
    3841    virtual ~QtAbstractWebPopup();
    3942
    4043    virtual void show(const QRect& geometry, int selectedIndex) = 0;
    4144    virtual void hide() = 0;
    42 
    43     static void setFactory(QtAbstractWebPopupFactory* factory);
    44     static QtAbstractWebPopup* create(PopupMenuClient* client);
     45    virtual void populate(const QFont& font, const QList<Item>& items) = 0;
     46    virtual void setParent(QWidget* parent) = 0;
    4547
    4648protected:
    47     PopupMenuClient* client();
     49    void popupDidHide(bool acceptSuggestions);
     50    void valueChanged(int index);
    4851
    4952private:
     53    friend class PopupMenu;
    5054    PopupMenuClient* m_client;
    51     static QtAbstractWebPopupFactory* m_factory;
    5255};
    5356
  • trunk/WebKit/qt/ChangeLog

    r52928 r53005  
     12010-01-08  Luiz Agostini  <luiz.agostini@openbossa.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Delegation client
     6        https://bugs.webkit.org/show_bug.cgi?id=32826
     7
     8        Added method createPopup to ChromeClientQt used to create popups.
     9        QtFallbackWebPopup moved from WebCore/platform/qt to
     10        WebKit/qt/WebCoreSupport.
     11
     12        * WebCoreSupport/ChromeClientQt.cpp:
     13        (WebCore::ChromeClientQt::createPopup):
     14        * WebCoreSupport/ChromeClientQt.h:
     15        * WebCoreSupport/QtFallbackWebPopup.cpp: Added.
     16        (WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
     17        (WebCore::QtFallbackWebPopup::show):
     18        (WebCore::QtFallbackWebPopup::populate):
     19        (WebCore::QtFallbackWebPopup::showPopup):
     20        (WebCore::QtFallbackWebPopup::hidePopup):
     21        (WebCore::QtFallbackWebPopup::activeChanged):
     22        (WebCore::QtFallbackWebPopup::setParent):
     23        * WebCoreSupport/QtFallbackWebPopup.h: Added.
     24        (WebCore::QtFallbackWebPopup::hide):
     25
    1262010-01-07  Yael Aharon  <yael.aharon@nokia.com>
    227
  • trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp

    r52152 r53005  
    3939#include "WindowFeatures.h"
    4040#include "DatabaseTracker.h"
     41#include "QtFallbackWebPopup.h"
     42#include "QWebPageClient.h"
    4143#include "SecurityOrigin.h"
    42 #include "QWebPageClient.h"
    4344
    4445#include "qwebpage.h"
     
    466467}
    467468
    468 }
     469QtAbstractWebPopup* ChromeClientQt::createPopup()
     470{
     471    return new QtFallbackWebPopup;
     472}
     473
     474}
  • trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.h

    r50351 r53005  
    4343    class Page;
    4444    struct FrameLoadRequest;
     45    class QtAbstractWebPopup;
    4546
    4647    class ChromeClientQt : public ChromeClient
     
    135136        virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
    136137
     138        QtAbstractWebPopup* createPopup();
     139
    137140        QWebPage* m_webPage;
    138141        WebCore::KURL lastHoverURL;
  • trunk/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp

    r53004 r53005  
    3434// QtFallbackWebPopup
    3535
    36 QtFallbackWebPopup::QtFallbackWebPopup(PopupMenuClient* client)
    37     : QtAbstractWebPopup(client)
     36QtFallbackWebPopup::QtFallbackWebPopup()
     37    : QtAbstractWebPopup()
    3838    , m_popupVisible(false)
    3939{
    40     setFont(QtAbstractWebPopup::client()->menuStyle().font().font());
    4140    connect(this, SIGNAL(activated(int)),
    4241            SLOT(activeChanged(int)), Qt::QueuedConnection);
     
    4645void QtFallbackWebPopup::show(const QRect& geometry, int selectedIndex)
    4746{
    48     populate();
    4947    setCurrentIndex(selectedIndex);
    5048
     49    /*
    5150    QWidget* parent = 0;
    5251    if (client()->hostWindow() && client()->hostWindow()->platformPageClient())
     
    5453
    5554    setParent(parent);
     55    */
     56
    5657    setGeometry(QRect(geometry.left(), geometry.top(), geometry.width(), sizeHint().height()));
    5758
     
    6162}
    6263
    63 void QtFallbackWebPopup::populate()
     64void QtFallbackWebPopup::populate(const QFont& font, const QList<Item>& items)
    6465{
    6566    clear();
     
    6869    Q_ASSERT(model);
    6970
    70     int size = client()->listSize();
    71     for (int i = 0; i < size; i++) {
    72         if (client()->itemIsSeparator(i))
     71    setFont(font);
     72    for (int i = 0; i < items.size(); ++i) {
     73        switch (items[i].type) {
     74        case QtAbstractWebPopup::Item::Separator:
    7375            insertSeparator(i);
    74         else {
    75             insertItem(i, client()->itemText(i));
    76 
    77             if (model && !client()->itemIsEnabled(i))
    78                 model->item(i)->setEnabled(false);
     76            break;
     77        case QtAbstractWebPopup::Item::Group:
     78            insertItem(i, items[i].text);
     79            model->item(i)->setEnabled(false);
     80            break;
     81        case QtAbstractWebPopup::Item::Option:
     82            insertItem(i, items[i].text);
     83            model->item(i)->setEnabled(items[i].enabled);
     84            break;
    7985        }
    8086    }
     
    104110
    105111    m_popupVisible = false;
    106     client()->popupDidHide(true);
     112    popupDidHide(true);
    107113}
    108114
     
    112118        return;
    113119
    114     client()->valueChanged(index);
     120    valueChanged(index);
     121}
     122
     123void QtFallbackWebPopup::setParent(QWidget* parent)
     124{
     125    QComboBox::setParent(parent);
    115126}
    116127
  • trunk/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h

    r53004 r53005  
    2929    Q_OBJECT
    3030public:
    31     QtFallbackWebPopup(PopupMenuClient* client);
     31    QtFallbackWebPopup();
    3232
    3333    virtual void show(const QRect& geometry, int selectedIndex);
    3434    virtual void hide() { hidePopup(); }
     35    virtual void populate(const QFont& font, const QList<Item>& items);
     36    virtual void setParent(QWidget* parent);
    3537
    3638private slots:
     
    4042    bool m_popupVisible;
    4143
    42     void populate();
    4344
    4445    virtual void showPopup();
Note: See TracChangeset for help on using the changeset viewer.