Changeset 52199 in webkit


Ignore:
Timestamp:
Dec 16, 2009 9:27:09 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-16 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Implement combobox delegate for Qt
https://bugs.webkit.org/show_bug.cgi?id=32550

Refactoring of class QWebPopup.

Class QWebPopup has been split in QtAbstractWebPopup and QtFallbackWebPopup.
Both new classes are now in corresponding files and files QWebPopup.* have been removed.

Custom combo popup classes will inherit from QtAbstractWebPopup. It is not the public API as it is
in WebCore and will not be visible by users of QtWebKit. It will be used in implementation of
public QtWebKit combobox popup delegation API.

Class QtFallbackWebPopup inherits from QtAbstractWebPopup and implements the currently used combobox popup.
It needs to be improved to provide standard features that are missing like style or indentation.

No behavior changes.

  • WebCore.pro:
  • platform/PopupMenu.h:
  • platform/qt/PopupMenuQt.cpp: (WebCore::PopupMenu::PopupMenu):
  • platform/qt/QWebPopup.cpp: Removed.
  • platform/qt/QWebPopup.h: Removed.
  • platform/qt/QtAbstractWebPopup.cpp: Added. (WebCore::QtAbstractWebPopup::QtAbstractWebPopup): (WebCore::QtAbstractWebPopup::~QtAbstractWebPopup): (WebCore::QtAbstractWebPopup::client):
  • platform/qt/QtAbstractWebPopup.h: Added.
  • platform/qt/QtFallbackWebPopup.cpp: Added. (WebCore::QtFallbackWebPopup::QtFallbackWebPopup): (WebCore::QtFallbackWebPopup::show): (WebCore::QtFallbackWebPopup::populate): (WebCore::QtFallbackWebPopup::showPopup): (WebCore::QtFallbackWebPopup::hidePopup): (WebCore::QtFallbackWebPopup::activeChanged):
  • platform/qt/QtFallbackWebPopup.h: Added. (WebCore::QtFallbackWebPopup::hide):
Location:
trunk/WebCore
Files:
4 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52193 r52199  
     12009-12-16  Luiz Agostini  <luiz.agostini@openbossa.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Implement combobox delegate for Qt
     6        https://bugs.webkit.org/show_bug.cgi?id=32550
     7
     8        Refactoring of class QWebPopup.
     9
     10        Class QWebPopup has been split in QtAbstractWebPopup and QtFallbackWebPopup.
     11        Both new classes are now in corresponding files and files QWebPopup.* have been removed.
     12
     13        Custom combo popup classes will inherit from QtAbstractWebPopup. It is not the public API as it is
     14        in WebCore and will not be visible by users of QtWebKit. It will be used in implementation of
     15        public QtWebKit combobox popup delegation API.
     16
     17        Class QtFallbackWebPopup inherits from QtAbstractWebPopup and implements the currently used combobox popup.
     18        It needs to be improved to provide standard features that are missing like style or indentation.
     19
     20        No behavior changes.
     21
     22        * WebCore.pro:
     23        * platform/PopupMenu.h:
     24        * platform/qt/PopupMenuQt.cpp:
     25        (WebCore::PopupMenu::PopupMenu):
     26        * platform/qt/QWebPopup.cpp: Removed.
     27        * platform/qt/QWebPopup.h: Removed.
     28        * platform/qt/QtAbstractWebPopup.cpp: Added.
     29        (WebCore::QtAbstractWebPopup::QtAbstractWebPopup):
     30        (WebCore::QtAbstractWebPopup::~QtAbstractWebPopup):
     31        (WebCore::QtAbstractWebPopup::client):
     32        * platform/qt/QtAbstractWebPopup.h: Added.
     33        * platform/qt/QtFallbackWebPopup.cpp: Added.
     34        (WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
     35        (WebCore::QtFallbackWebPopup::show):
     36        (WebCore::QtFallbackWebPopup::populate):
     37        (WebCore::QtFallbackWebPopup::showPopup):
     38        (WebCore::QtFallbackWebPopup::hidePopup):
     39        (WebCore::QtFallbackWebPopup::activeChanged):
     40        * platform/qt/QtFallbackWebPopup.h: Added.
     41        (WebCore::QtFallbackWebPopup::hide):
     42
    1432009-12-15  Pavel Feldman  <pfeldman@chromium.org>
    244
  • trunk/WebCore/WebCore.pro

    r52103 r52199  
    19671967    platform/qt/ClipboardQt.h \
    19681968    platform/qt/QWebPageClient.h \
    1969     platform/qt/QWebPopup.h \
     1969    platform/qt/QtAbstractWebPopup.h \
     1970    platform/qt/QtFallbackWebPopup.h \
    19701971    platform/qt/RenderThemeQt.h \
    19711972    platform/qt/ScrollbarThemeQt.h \
     
    24262427    platform/qt/PlatformTouchPointQt.cpp \
    24272428    platform/qt/PopupMenuQt.cpp \
    2428     platform/qt/QWebPopup.cpp \
     2429    platform/qt/QtAbstractWebPopup.cpp \
     2430    platform/qt/QtFallbackWebPopup.cpp \
    24292431    platform/qt/RenderThemeQt.cpp \
    24302432    platform/qt/ScrollbarQt.cpp \
  • trunk/WebCore/platform/PopupMenu.h

    r52151 r52199  
    4343#elif PLATFORM(QT)
    4444namespace WebCore {
    45     class QWebPopup;
     45class QtAbstractWebPopup;
    4646}
    4747#elif PLATFORM(GTK)
     
    145145    RetainPtr<NSPopUpButtonCell> m_popup;
    146146#elif PLATFORM(QT)
    147     QWebPopup* m_popup;
     147    QtAbstractWebPopup* m_popup;
    148148#elif PLATFORM(WIN)
    149149    // ScrollBarClient
  • trunk/WebCore/platform/qt/PopupMenuQt.cpp

    r52151 r52199  
    22 * This file is part of the popup menu implementation for <select> elements in WebCore.
    33 *
    4  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     4 * Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
    55 * Copyright (C) 2006 Apple Computer, Inc.
    66 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
     
    2929#include "FrameView.h"
    3030#include "PopupMenuClient.h"
    31 #include "QWebPopup.h"
     31#include "QtAbstractWebPopup.h"
     32#include "QtFallbackWebPopup.h"
    3233
    3334namespace WebCore {
     
    3637    : m_popupClient(client)
    3738{
    38     m_popup = new QWebPopup(client);
     39    m_popup = new QtFallbackWebPopup(client);
    3940}
    4041
  • trunk/WebCore/platform/qt/QtAbstractWebPopup.cpp

    r52198 r52199  
    11/*
    2  *
    3  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
    43 *
    54 * This library is free software; you can redistribute it and/or
     
    1918 *
    2019 */
    21 #ifndef QWebPopup_h
    22 #define QWebPopup_h
     20#include "config.h"
     21#include "QtAbstractWebPopup.h"
    2322
    24 #include <QComboBox>
     23#include "PopupMenuStyle.h"
    2524
    26 #include "PopupMenuClient.h"
    2725
    2826namespace WebCore {
    2927
    30 class QWebPopup : private QComboBox {
    31     Q_OBJECT
    32 public:
    33     QWebPopup(PopupMenuClient* client);
     28// QAbstractWebPopup
    3429
    35     void show(const QRect& geometry, int selectedIndex);
    36     void hide() { hidePopup(); }
    37 
    38 private slots:
    39     void activeChanged(int);
    40 
    41 private:
    42     PopupMenuClient* m_client;
    43     bool m_popupVisible;
    44 
    45     void populate();
    46 
    47     virtual void showPopup();
    48     virtual void hidePopup();
    49 };
    50 
     30QtAbstractWebPopup::QtAbstractWebPopup(PopupMenuClient* client)
     31    : m_client(client)
     32{
     33    Q_ASSERT(m_client);
    5134}
    5235
    53 #endif
     36QtAbstractWebPopup::~QtAbstractWebPopup()
     37{
     38}
     39
     40PopupMenuClient* QtAbstractWebPopup::client()
     41{
     42    return m_client;
     43}
     44
     45} // namespace WebCore
  • trunk/WebCore/platform/qt/QtAbstractWebPopup.h

    r52198 r52199  
    11/*
    2  *
    3  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
    43 *
    54 * This library is free software; you can redistribute it and/or
     
    1918 *
    2019 */
    21 #ifndef QWebPopup_h
    22 #define QWebPopup_h
    23 
    24 #include <QComboBox>
     20#ifndef QtAbstractWebPopup_h
     21#define QtAbstractWebPopup_h
    2522
    2623#include "PopupMenuClient.h"
     24#include <QComboBox>
    2725
    2826namespace WebCore {
    2927
    30 class QWebPopup : private QComboBox {
    31     Q_OBJECT
     28class QtAbstractWebPopup {
    3229public:
    33     QWebPopup(PopupMenuClient* client);
     30    QtAbstractWebPopup(PopupMenuClient* client);
     31    virtual ~QtAbstractWebPopup();
    3432
    35     void show(const QRect& geometry, int selectedIndex);
    36     void hide() { hidePopup(); }
     33    virtual void show(const QRect& geometry, int selectedIndex) = 0;
     34    virtual void hide() = 0;
    3735
    38 private slots:
    39     void activeChanged(int);
     36protected:
     37    PopupMenuClient* client();
    4038
    4139private:
    4240    PopupMenuClient* m_client;
    43     bool m_popupVisible;
    44 
    45     void populate();
    46 
    47     virtual void showPopup();
    48     virtual void hidePopup();
    4941};
    5042
    5143}
    5244
    53 #endif
     45#endif // QtAbstractWebPopup_h
  • trunk/WebCore/platform/qt/QtFallbackWebPopup.cpp

    r52198 r52199  
    11/*
    2  *
    3  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
    43 *
    54 * This library is free software; you can redistribute it and/or
     
    2019 */
    2120#include "config.h"
    22 #include "QWebPopup.h"
     21#include "QtFallbackWebPopup.h"
     22
    2323#include "HostWindow.h"
    24 #include "PopupMenuStyle.h"
    2524#include "QWebPageClient.h"
    26 
    2725#include <QAbstractItemView>
    2826#include <QApplication>
     
    3331namespace WebCore {
    3432
    35 QWebPopup::QWebPopup(PopupMenuClient* client)
    36     : m_client(client)
     33// QtFallbackWebPopup
     34
     35QtFallbackWebPopup::QtFallbackWebPopup(PopupMenuClient* client)
     36    : QtAbstractWebPopup(client)
    3737    , m_popupVisible(false)
    3838{
    39     Q_ASSERT(m_client);
    40 
    41     setFont(m_client->menuStyle().font().font());
     39    setFont(QtAbstractWebPopup::client()->menuStyle().font().font());
    4240    connect(this, SIGNAL(activated(int)),
    4341            SLOT(activeChanged(int)), Qt::QueuedConnection);
     
    4543
    4644
    47 void QWebPopup::show(const QRect& geometry, int selectedIndex)
     45void QtFallbackWebPopup::show(const QRect& geometry, int selectedIndex)
    4846{
    4947    populate();
     
    5149
    5250    QWidget* parent = 0;
    53     if (m_client->hostWindow() && m_client->hostWindow()->platformPageClient())
    54        parent = m_client->hostWindow()->platformPageClient()->ownerWidget();
     51    if (client()->hostWindow() && client()->hostWindow()->platformPageClient())
     52       parent = client()->hostWindow()->platformPageClient()->ownerWidget();
    5553
    5654    setParent(parent);
     
    6260}
    6361
    64 void QWebPopup::populate()
     62void QtFallbackWebPopup::populate()
    6563{
    6664    clear();
    67     Q_ASSERT(m_client);
    6865
    6966    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(QComboBox::model());
    7067    Q_ASSERT(model);
    7168
    72     int size = m_client->listSize();
     69    int size = client()->listSize();
    7370    for (int i = 0; i < size; i++) {
    74         if (m_client->itemIsSeparator(i))
     71        if (client()->itemIsSeparator(i))
    7572            insertSeparator(i);
    7673        else {
    77             insertItem(i, m_client->itemText(i));
     74            insertItem(i, client()->itemText(i));
    7875
    79             if (model && !m_client->itemIsEnabled(i))
     76            if (model && !client()->itemIsEnabled(i))
    8077                model->item(i)->setEnabled(false);
    8178        }
     
    8380}
    8481
    85 void QWebPopup::showPopup()
     82void QtFallbackWebPopup::showPopup()
    8683{
    8784    QComboBox::showPopup();
     
    8986}
    9087
    91 void QWebPopup::hidePopup()
     88void QtFallbackWebPopup::hidePopup()
    9289{
    9390    QWidget* activeFocus = QApplication::focusWidget();
     
    106103
    107104    m_popupVisible = false;
    108     m_client->popupDidHide();
     105    client()->popupDidHide();
    109106}
    110107
    111 void QWebPopup::activeChanged(int index)
     108void QtFallbackWebPopup::activeChanged(int index)
    112109{
    113110    if (index < 0)
    114111        return;
    115112
    116     m_client->valueChanged(index);
     113    client()->valueChanged(index);
    117114}
    118115
    119 } // namespace WebCore
    120 
    121 #include "moc_QWebPopup.cpp"
     116}
  • trunk/WebCore/platform/qt/QtFallbackWebPopup.h

    r52198 r52199  
    11/*
    2  *
    3  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
    43 *
    54 * This library is free software; you can redistribute it and/or
     
    1918 *
    2019 */
    21 #ifndef QWebPopup_h
    22 #define QWebPopup_h
     20#ifndef QtFallbackWebPopup_h
     21#define QtFallbackWebPopup_h
    2322
     23#include "QtAbstractWebPopup.h"
    2424#include <QComboBox>
    25 
    26 #include "PopupMenuClient.h"
    2725
    2826namespace WebCore {
    2927
    30 class QWebPopup : private QComboBox {
     28class QtFallbackWebPopup : private QComboBox, public QtAbstractWebPopup {
    3129    Q_OBJECT
    3230public:
    33     QWebPopup(PopupMenuClient* client);
     31    QtFallbackWebPopup(PopupMenuClient* client);
    3432
    35     void show(const QRect& geometry, int selectedIndex);
    36     void hide() { hidePopup(); }
     33    virtual void show(const QRect& geometry, int selectedIndex);
     34    virtual void hide() { hidePopup(); }
    3735
    3836private slots:
     
    4038
    4139private:
    42     PopupMenuClient* m_client;
    4340    bool m_popupVisible;
    4441
     
    5148}
    5249
    53 #endif
     50#endif // QtFallbackWebPopup_h
Note: See TracChangeset for help on using the changeset viewer.