COMMIT_MESSAGE

 1WebCore: [Qt] Custom select popups.
 2https://bugs.webkit.org/show_bug.cgi?id=33418
 3
 4Reviewed by NOBODY (OOPS!).
 5
 6class QWebDelegateSelectPopup added to Qt API.
 7classes WebCore::PopupMenu and WebCore::QtAbstractWebPopup have changed to
 8support the new API.
 9
 10* WebCore.pro:
 11* platform/qt/PopupMenuQt.cpp:
 12(WebCore::PopupMenu::show):
 13* platform/qt/QtAbstractWebPopup.cpp:
 14(WebCore::QtAbstractWebPopup::QtAbstractWebPopup):
 15(WebCore::QtAbstractWebPopup::itemType):
 16* platform/qt/QtAbstractWebPopup.h:
 17(WebCore::QtAbstractWebPopup::):
 18(WebCore::QtAbstractWebPopup::itemText):
 19(WebCore::QtAbstractWebPopup::itemToolTip):
 20(WebCore::QtAbstractWebPopup::itemIsEnabled):
 21(WebCore::QtAbstractWebPopup::itemCount):
 22(WebCore::QtAbstractWebPopup::view):
 23(WebCore::QtAbstractWebPopup::geometry):
 24(WebCore::QtAbstractWebPopup::currentIndex):
 25(WebCore::QtAbstractWebPopup::font):
 26
 27WebKit/qt: Support for combobox popup customizations.
 28
 29Reviewed by NOBODY (OOPS!).
 30
 31Combobox popup customization can be made providing an instance of
 32QWebDelegateSelectPopupFactory to QWebPage. The factory will be used to create
 33QWebDelegateSelectPopup objects when needed. QWebDelegateSelectPopup class is the
 34base class for custom combobox popups.
 35
 36QWebDelegateSelectPopupFactory inherited classes must implement method create and
 37return an object of class QWebDelegateSelectPopup.
 38
 39[Qt] Custom select popups.
 40https://bugs.webkit.org/show_bug.cgi?id=33418
 41
 42* Api/headers.pri:
 43* Api/qwebdelegateselectpopup.cpp: Added.
 44(QWebDelegateSelectPopup::QWebDelegateSelectPopup):
 45(QWebDelegateSelectPopup::~QWebDelegateSelectPopup):
 46(QWebDelegateSelectPopup::informClosed):
 47(QWebDelegateSelectPopup::setCurrentIndex):
 48(QWebDelegateSelectPopup::view):
 49(QWebDelegateSelectPopup::geometry):
 50(QWebDelegateSelectPopup::currentIndex):
 51(QWebDelegateSelectPopup::itemType):
 52(QWebDelegateSelectPopup::itemText):
 53(QWebDelegateSelectPopup::itemToolTip):
 54(QWebDelegateSelectPopup::itemIsEnabled):
 55(QWebDelegateSelectPopup::itemCount):
 56* Api/qwebdelegateselectpopup.h: Added.
 57* Api/qwebdelegateselectpopup_p.h: Added.
 58(QWebDelegateSelectPopupPrivate::QWebDelegateSelectPopupPrivate):
 59* Api/qwebpage.cpp:
 60(QWebPage::setSelectPopupDelegateFactory):
 61* Api/qwebpage.h:
 62* WebCoreSupport/ChromeClientQt.cpp:
 63(WebCore::QWebPopupWrapper::QWebPopupWrapper):
 64(WebCore::QWebPopupWrapper::~QWebPopupWrapper):
 65(WebCore::QWebPopupWrapper::show):
 66(WebCore::QWebPopupWrapper::hide):
 67(WebCore::ChromeClientQt::ChromeClientQt):
 68(WebCore::ChromeClientQt::setSelectPopupDelegateFactory):
 69(WebCore::ChromeClientQt::createSelectPopup):
 70* WebCoreSupport/ChromeClientQt.h:
 71* WebCoreSupport/QtFallbackWebPopup.cpp:
 72(WebCore::QtFallbackWebPopupCombo::QtFallbackWebPopupCombo):
 73(WebCore::QtFallbackWebPopupCombo::showPopup):
 74(WebCore::QtFallbackWebPopupCombo::hidePopup):
 75(WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
 76(WebCore::QtFallbackWebPopup::~QtFallbackWebPopup):
 77(WebCore::QtFallbackWebPopup::show):
 78(WebCore::QtFallbackWebPopup::hide):
 79(WebCore::QtFallbackWebPopup::populate):
 80* WebCoreSupport/QtFallbackWebPopup.h:

WebCore/ChangeLog

 12010-01-19 Luiz Agostini <luiz.agostini@openbossa.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [Qt] Custom select popups.
 6 https://bugs.webkit.org/show_bug.cgi?id=33418
 7
 8 class QWebDelegateSelectPopup added to Qt API.
 9 classes WebCore::PopupMenu and WebCore::QtAbstractWebPopup have changed to
 10 support the new API.
 11
 12 * WebCore.pro:
 13 * platform/qt/PopupMenuQt.cpp:
 14 (WebCore::PopupMenu::show):
 15 * platform/qt/QtAbstractWebPopup.cpp:
 16 (WebCore::QtAbstractWebPopup::QtAbstractWebPopup):
 17 (WebCore::QtAbstractWebPopup::itemType):
 18 * platform/qt/QtAbstractWebPopup.h:
 19 (WebCore::QtAbstractWebPopup::):
 20 (WebCore::QtAbstractWebPopup::itemText):
 21 (WebCore::QtAbstractWebPopup::itemToolTip):
 22 (WebCore::QtAbstractWebPopup::itemIsEnabled):
 23 (WebCore::QtAbstractWebPopup::itemCount):
 24 (WebCore::QtAbstractWebPopup::view):
 25 (WebCore::QtAbstractWebPopup::geometry):
 26 (WebCore::QtAbstractWebPopup::currentIndex):
 27 (WebCore::QtAbstractWebPopup::font):
 28
1292010-01-08 Adam Barth <abarth@webkit.org>
230
331 Unreviewed. Fix namespace indent for SecurityOrigin.h.

WebCore/WebCore.pro

@@SOURCES += \
24722472 ../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \
24732473 ../WebKit/qt/Api/qwebframe.cpp \
24742474 ../WebKit/qt/Api/qgraphicswebview.cpp \
 2475 ../WebKit/qt/Api/qwebdelegateselectpopup.cpp \
24752476 ../WebKit/qt/Api/qwebpage.cpp \
24762477 ../WebKit/qt/Api/qwebview.cpp \
24772478 ../WebKit/qt/Api/qwebelement.cpp \

WebCore/platform/qt/PopupMenuQt.cpp

@@PopupMenu::~PopupMenu()
4646 delete m_popup;
4747}
4848
49 static QList<QtAbstractWebPopup::Item> getItems(PopupMenuClient* client)
50 {
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 
7249void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
7350{
7451 ChromeClientQt* chromeClient = static_cast<ChromeClientQt*>(
7552 view->frame()->page()->chrome()->client());
7653 ASSERT(chromeClient);
7754
78  if (!m_popup) {
79  m_popup = chromeClient->createPopup();
80  m_popup->m_client = m_popupClient;
81  }
 55 if (!m_popup)
 56 m_popup = chromeClient->createSelectPopup();
 57
 58 m_popup->m_client = m_popupClient;
 59 m_popup->m_currentIndex = index;
 60 m_popup->m_view = chromeClient->platformPageClient()->ownerWidget();
 61
 62 QRect geometry(rect);
 63 geometry.moveTopLeft(view->contentsToWindow(rect.topLeft()));
 64 m_popup->m_geometry = geometry;
8265
83  m_popup->setParent(chromeClient->platformPageClient()->ownerWidget());
84  m_popup->populate(m_popupClient->menuStyle().font().font(),
85  getItems(m_popupClient));
 66 m_popup->show();
8667
87  QRect bounds = rect;
88  bounds.moveTopLeft(view->contentsToWindow(rect.topLeft()));
89  m_popup->show(bounds, index);
9068}
9169
9270void PopupMenu::hide()

WebCore/platform/qt/QtAbstractWebPopup.cpp

@@namespace WebCore {
2727
2828QtAbstractWebPopup::QtAbstractWebPopup()
2929 : m_client(0)
 30 , m_view(0)
 31 , m_currentIndex(-1)
3032{
3133}
3234

@@void QtAbstractWebPopup::valueChanged(int index)
4648 m_client->valueChanged(index);
4749}
4850
 51QtAbstractWebPopup::ItemType QtAbstractWebPopup::itemType(int idx) const
 52{
 53 if (m_client->itemIsSeparator(idx))
 54 return Separator;
 55 if (m_client->itemIsLabel(idx))
 56 return Group;
 57 return Option;
 58}
 59
4960} // namespace WebCore

WebCore/platform/qt/QtAbstractWebPopup.h

2020#ifndef QtAbstractWebPopup_h
2121#define QtAbstractWebPopup_h
2222
 23#include "PopupMenuClient.h"
 24
2325#include <QFont>
2426#include <QList>
2527#include <QRect>
 28#include <QWidget>
2629
2730namespace WebCore {
2831
29 class PopupMenuClient;
3032
3133class QtAbstractWebPopup {
3234public:
33  struct Item {
34  enum { Option, Group, Separator } type;
35  QString text;
36  QString toolTip;
37  bool enabled;
38  };
 35 enum ItemType { Option, Group, Separator };
 36
 37 ItemType itemType(int) const;
 38 QString itemText(int idx) const { return m_client->itemText(idx); }
 39 QString itemToolTip(int idx) const { return m_client->itemToolTip(idx); }
 40 bool itemIsEnabled(int idx) const { return m_client->itemIsEnabled(idx); }
 41 int itemCount() const { return m_client->listSize(); }
 42
 43 QWidget* view() { return m_view; }
 44 QRect geometry() const { return m_geometry; }
 45 int currentIndex() const { return m_currentIndex; }
3946
4047 QtAbstractWebPopup();
4148 virtual ~QtAbstractWebPopup();
4249
43  virtual void show(const QRect& geometry, int selectedIndex) = 0;
 50 virtual void show() = 0;
4451 virtual void hide() = 0;
45  virtual void populate(const QFont& font, const QList<Item>& items) = 0;
46  virtual void setParent(QWidget* parent) = 0;
4752
48 protected:
4953 void popupDidHide(bool acceptSuggestions);
5054 void valueChanged(int index);
5155
 56 QFont font() { return m_client->menuStyle().font().font(); }
 57
5258private:
5359 friend class PopupMenu;
5460 PopupMenuClient* m_client;
 61 QWidget* m_view;
 62 int m_currentIndex;
 63 QRect m_geometry;
5564};
5665
5766}

WebKit/qt/Api/headers.pri

@@WEBKIT_API_HEADERS = $$PWD/qwebframe.h \
1111 $$PWD/qwebpluginfactory.h \
1212 $$PWD/qwebhistory.h \
1313 $$PWD/qwebinspector.h \
14  $$PWD/qwebkitversion.h
 14 $$PWD/qwebkitversion.h \
 15 $$PWD/qwebdelegateselectpopup.h \
 16 $$PWD/qwebdelegateselectpopup_p.h

WebKit/qt/Api/qwebdelegateselectpopup.cpp

 1/*
 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 *
 19 */
 20
 21#include "config.h"
 22#include "qwebdelegateselectpopup.h"
 23
 24#include "QtAbstractWebPopup.h"
 25#include "qwebdelegateselectpopup_p.h"
 26
 27QWebDelegateSelectPopup::QWebDelegateSelectPopup()
 28 : d(new QWebDelegateSelectPopupPrivate())
 29{
 30}
 31
 32QWebDelegateSelectPopup::~QWebDelegateSelectPopup()
 33{
 34 delete d;
 35}
 36
 37void QWebDelegateSelectPopup::informClosed()
 38{
 39 d->corePopup->popupDidHide(true);
 40}
 41
 42void QWebDelegateSelectPopup::setCurrentIndex(int idx)
 43{
 44 d->corePopup->valueChanged(idx);
 45}
 46
 47QWidget* QWebDelegateSelectPopup::view()
 48{
 49 return d->corePopup->view();
 50}
 51
 52QRect QWebDelegateSelectPopup::geometry() const
 53{
 54 return d->corePopup->geometry();
 55}
 56
 57int QWebDelegateSelectPopup::currentIndex() const
 58{
 59 return d->corePopup->currentIndex();
 60}
 61
 62QWebDelegateSelectPopup::ItemType QWebDelegateSelectPopup::itemType(int idx) const
 63{
 64 switch (d->corePopup->itemType(idx)) {
 65 case WebCore::QtAbstractWebPopup::Group:
 66 return Group;
 67 case WebCore::QtAbstractWebPopup::Option:
 68 return Option;
 69 case WebCore::QtAbstractWebPopup::Separator:
 70 return Separator;
 71 }
 72 return Option;
 73}
 74
 75QString QWebDelegateSelectPopup::itemText(int idx) const
 76{
 77 return d->corePopup->itemText(idx);
 78}
 79
 80QString QWebDelegateSelectPopup::itemToolTip(int idx) const
 81{
 82 return d->corePopup->itemToolTip(idx);
 83}
 84
 85bool QWebDelegateSelectPopup::itemIsEnabled(int idx) const
 86{
 87 return d->corePopup->itemIsEnabled(idx);
 88}
 89
 90int QWebDelegateSelectPopup::itemCount() const
 91{
 92 return d->corePopup->itemCount();
 93}
 94

WebKit/qt/Api/qwebdelegateselectpopup.h

 1/*
 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 *
 19 */
 20
 21#ifndef qwebdelegateselectpopup_h
 22#define qwebdelegateselectpopup_h
 23
 24#include "qwebkitglobal.h"
 25#include <QList>
 26#include <QRect>
 27#include <QString>
 28#include <QWidget>
 29
 30class QWebDelegateSelectPopupPrivate;
 31
 32namespace WebCore {
 33class QWebPopupWrapper;
 34}
 35
 36class QWEBKIT_EXPORT QWebDelegateSelectPopup {
 37public:
 38 QWebDelegateSelectPopup();
 39 virtual ~QWebDelegateSelectPopup();
 40
 41 enum ItemType { Option, Group, Separator };
 42 ItemType itemType(int) const;
 43 QString itemText(int) const;
 44 QString itemToolTip(int) const;
 45 bool itemIsEnabled(int) const;
 46 int itemCount() const;
 47
 48 QWidget* view();
 49 QRect geometry() const;
 50 int currentIndex() const;
 51
 52 virtual void open() = 0;
 53 virtual void close() = 0;
 54
 55protected:
 56 void setCurrentIndex(int index);
 57 void informClosed();
 58
 59private:
 60 friend class WebCore::QWebPopupWrapper;
 61 QWebDelegateSelectPopupPrivate* d;
 62};
 63
 64class QWebDelegateSelectPopupFactory {
 65public:
 66 virtual QWebDelegateSelectPopup* create() = 0;
 67};
 68
 69
 70
 71#endif // qwebdelegateselectpopup_h

WebKit/qt/Api/qwebdelegateselectpopup_p.h

 1/*
 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 *
 19 */
 20
 21#ifndef qwebdelegateselectpopup_p_h
 22#define qwebdelegateselectpopup_p_h
 23
 24#include "qwebdelegateselectpopup.h"
 25
 26namespace WebCore {
 27class QtAbstractWebPopup;
 28}
 29
 30class QWebDelegateSelectPopupPrivate {
 31public:
 32 WebCore::QtAbstractWebPopup* corePopup;
 33 QWebDelegateSelectPopupPrivate() : corePopup(0) {}
 34};
 35
 36
 37#endif // qwebdelegateselectpopup_p_h

WebKit/qt/Api/qwebpage.cpp

11/*
2  Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
 2 Copyright (C) 2008, 2009, 2010 Nokia Corporation and/or its subsidiary(-ies)
33 Copyright (C) 2007 Staikos Computing Services Inc.
44 Copyright (C) 2007 Apple Inc.
55

@@QWebPage::~QWebPage()
17431743 delete d;
17441744}
17451745
 1746void QWebPage::setSelectPopupDelegateFactory(QWebDelegateSelectPopupFactory* factory)
 1747{
 1748 d->chromeClient->setSelectPopupDelegateFactory(factory);
 1749}
 1750
17461751/*!
17471752 Returns the main frame of the page.
17481753

WebKit/qt/Api/qwebpage.h

11/*
2  Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
 2 Copyright (C) 2008, 2009, 2010 Nokia Corporation and/or its subsidiary(-ies)
33 Copyright (C) 2007 Staikos Computing Services Inc.
44
55 This library is free software; you can redistribute it and/or

@@class QWebPluginFactory;
4949class QWebHitTestResult;
5050class QWebHistoryItem;
5151
 52class QWebDelegateSelectPopupFactory;
 53
5254namespace WebCore {
5355 class ChromeClientQt;
5456 class EditorClientQt;

@@public:
203205 void setView(QWidget *view);
204206 QWidget *view() const;
205207
 208 void setSelectPopupDelegateFactory(QWebDelegateSelectPopupFactory* factory);
 209
206210 bool isModified() const;
207211#ifndef QT_NO_UNDOSTACK
208212 QUndoStack *undoStack() const;

WebKit/qt/ChangeLog

 12010-01-19 Luiz Agostini <luiz.agostini@openbossa.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Support for combobox popup customizations.
 6
 7 Combobox popup customization can be made providing an instance of
 8 QWebDelegateSelectPopupFactory to QWebPage. The factory will be used to create
 9 QWebDelegateSelectPopup objects when needed. QWebDelegateSelectPopup class is the
 10 base class for custom combobox popups.
 11
 12 QWebDelegateSelectPopupFactory inherited classes must implement method create and
 13 return an object of class QWebDelegateSelectPopup.
 14
 15 [Qt] Custom select popups.
 16 https://bugs.webkit.org/show_bug.cgi?id=33418
 17
 18 * Api/headers.pri:
 19 * Api/qwebdelegateselectpopup.cpp: Added.
 20 (QWebDelegateSelectPopup::QWebDelegateSelectPopup):
 21 (QWebDelegateSelectPopup::~QWebDelegateSelectPopup):
 22 (QWebDelegateSelectPopup::informClosed):
 23 (QWebDelegateSelectPopup::setCurrentIndex):
 24 (QWebDelegateSelectPopup::view):
 25 (QWebDelegateSelectPopup::geometry):
 26 (QWebDelegateSelectPopup::currentIndex):
 27 (QWebDelegateSelectPopup::itemType):
 28 (QWebDelegateSelectPopup::itemText):
 29 (QWebDelegateSelectPopup::itemToolTip):
 30 (QWebDelegateSelectPopup::itemIsEnabled):
 31 (QWebDelegateSelectPopup::itemCount):
 32 * Api/qwebdelegateselectpopup.h: Added.
 33 * Api/qwebdelegateselectpopup_p.h: Added.
 34 (QWebDelegateSelectPopupPrivate::QWebDelegateSelectPopupPrivate):
 35 * Api/qwebpage.cpp:
 36 (QWebPage::setSelectPopupDelegateFactory):
 37 * Api/qwebpage.h:
 38 * WebCoreSupport/ChromeClientQt.cpp:
 39 (WebCore::QWebPopupWrapper::QWebPopupWrapper):
 40 (WebCore::QWebPopupWrapper::~QWebPopupWrapper):
 41 (WebCore::QWebPopupWrapper::show):
 42 (WebCore::QWebPopupWrapper::hide):
 43 (WebCore::ChromeClientQt::ChromeClientQt):
 44 (WebCore::ChromeClientQt::setSelectPopupDelegateFactory):
 45 (WebCore::ChromeClientQt::createSelectPopup):
 46 * WebCoreSupport/ChromeClientQt.h:
 47 * WebCoreSupport/QtFallbackWebPopup.cpp:
 48 (WebCore::QtFallbackWebPopupCombo::QtFallbackWebPopupCombo):
 49 (WebCore::QtFallbackWebPopupCombo::showPopup):
 50 (WebCore::QtFallbackWebPopupCombo::hidePopup):
 51 (WebCore::QtFallbackWebPopup::QtFallbackWebPopup):
 52 (WebCore::QtFallbackWebPopup::~QtFallbackWebPopup):
 53 (WebCore::QtFallbackWebPopup::show):
 54 (WebCore::QtFallbackWebPopup::hide):
 55 (WebCore::QtFallbackWebPopup::populate):
 56 * WebCoreSupport/QtFallbackWebPopup.h:
 57
1582010-01-08 Luiz Agostini <luiz.agostini@openbossa.org>
259
360 Reviewed by Kenneth Rohde Christiansen.

WebKit/qt/WebCoreSupport/ChromeClientQt.cpp

11/*
 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
23 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
34 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
45 *

4243#include "QWebPageClient.h"
4344#include "SecurityOrigin.h"
4445
 46#include "qwebdelegateselectpopup.h"
 47#include "qwebdelegateselectpopup_p.h"
4548#include "qwebpage.h"
4649#include "qwebpage_p.h"
4750#include "qwebframe_p.h"

@@namespace WebCore
5659{
5760
5861
 62class QWebPopupWrapper : public QtAbstractWebPopup {
 63public:
 64 QWebPopupWrapper(QWebDelegateSelectPopup* popup);
 65 ~QWebPopupWrapper();
 66
 67public:
 68 virtual void show();
 69 virtual void hide();
 70
 71private:
 72 QWebDelegateSelectPopup* m_popup;
 73};
 74
 75QWebPopupWrapper::QWebPopupWrapper(QWebDelegateSelectPopup* popup)
 76 : m_popup(popup)
 77{
 78 m_popup->d->corePopup = this;
 79}
 80
 81QWebPopupWrapper::~QWebPopupWrapper()
 82{
 83 delete m_popup;
 84}
 85
 86void QWebPopupWrapper::show()
 87{
 88 m_popup->open();
 89}
 90
 91void QWebPopupWrapper::hide()
 92{
 93 m_popup->close();
 94}
 95
5996ChromeClientQt::ChromeClientQt(QWebPage* webPage)
6097 : m_webPage(webPage)
 98 , m_selectPopupFactory(0)
6199{
62100 toolBarsVisible = statusBarVisible = menuBarVisible = true;
63101}

@@ChromeClientQt::~ChromeClientQt()
67105
68106}
69107
 108void ChromeClientQt::setSelectPopupDelegateFactory(QWebDelegateSelectPopupFactory* popupFactory)
 109{
 110 m_selectPopupFactory = popupFactory;
 111}
 112
70113void ChromeClientQt::setWindowRect(const FloatRect& rect)
71114{
72115 if (!m_webPage)

@@void ChromeClientQt::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
466509 notImplemented();
467510}
468511
469 QtAbstractWebPopup* ChromeClientQt::createPopup()
 512QtAbstractWebPopup* ChromeClientQt::createSelectPopup()
470513{
 514 if (m_selectPopupFactory)
 515 return new QWebPopupWrapper(m_selectPopupFactory->create());
471516 return new QtFallbackWebPopup;
472517}
473518

WebKit/qt/WebCoreSupport/ChromeClientQt.h

11/*
 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
23 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
34 *
45 * All rights reserved.

3536#include "PlatformString.h"
3637
3738class QWebPage;
 39class QWebDelegateSelectPopupFactory;
3840
3941namespace WebCore {
4042

@@namespace WebCore {
135137
136138 virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
137139
138  QtAbstractWebPopup* createPopup();
 140 QtAbstractWebPopup* createSelectPopup();
 141
 142 void setSelectPopupDelegateFactory(QWebDelegateSelectPopupFactory* popupFactory);
139143
140144 QWebPage* m_webPage;
141145 WebCore::KURL lastHoverURL;

@@namespace WebCore {
145149 bool toolBarsVisible;
146150 bool statusBarVisible;
147151 bool menuBarVisible;
 152
 153 QWebDelegateSelectPopupFactory* m_selectPopupFactory;
148154 };
149155}
150156

WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp

3131
3232namespace WebCore {
3333
 34QtFallbackWebPopupCombo::QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup)
 35 : m_ownerPopup(ownerPopup)
 36{
 37}
 38
 39void QtFallbackWebPopupCombo::showPopup()
 40{
 41 QComboBox::showPopup();
 42 m_ownerPopup.m_popupVisible = true;
 43}
 44
 45void QtFallbackWebPopupCombo::hidePopup()
 46{
 47 QWidget* activeFocus = QApplication::focusWidget();
 48 if (activeFocus && activeFocus == QComboBox::view()
 49 && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
 50 QInputContext* qic = activeFocus->inputContext();
 51 if (qic) {
 52 qic->reset();
 53 qic->setFocusWidget(0);
 54 }
 55 }
 56
 57 QComboBox::hidePopup();
 58 if (!m_ownerPopup.m_popupVisible)
 59 return;
 60
 61 m_ownerPopup.m_popupVisible = false;
 62 m_ownerPopup.popupDidHide(true);
 63}
 64
3465// QtFallbackWebPopup
3566
3667QtFallbackWebPopup::QtFallbackWebPopup()
3768 : QtAbstractWebPopup()
3869 , m_popupVisible(false)
 70 , m_combo(new QtFallbackWebPopupCombo(*this))
3971{
40  connect(this, SIGNAL(activated(int)),
 72 connect(m_combo, SIGNAL(activated(int)),
4173 SLOT(activeChanged(int)), Qt::QueuedConnection);
4274}
4375
44 
45 void QtFallbackWebPopup::show(const QRect& geometry, int selectedIndex)
 76QtFallbackWebPopup::~QtFallbackWebPopup()
4677{
47  setCurrentIndex(selectedIndex);
48 
49  /*
50  QWidget* parent = 0;
51  if (client()->hostWindow() && client()->hostWindow()->platformPageClient())
52  parent = client()->hostWindow()->platformPageClient()->ownerWidget();
 78 delete m_combo;
 79}
5380
54  setParent(parent);
55  */
 81void QtFallbackWebPopup::show()
 82{
 83 populate();
 84 m_combo->setParent(view());
 85 m_combo->setCurrentIndex(currentIndex());
5686
57  setGeometry(QRect(geometry.left(), geometry.top(), geometry.width(), sizeHint().height()));
 87 QRect rect = geometry();
 88 m_combo->setGeometry(QRect(rect.left(), rect.top(),
 89 rect.width(), m_combo->sizeHint().height()));
5890
5991 QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton,
6092 Qt::LeftButton, Qt::NoModifier);
61  QCoreApplication::sendEvent(this, &event);
 93 QCoreApplication::sendEvent(m_combo, &event);
6294}
6395
64 void QtFallbackWebPopup::populate(const QFont& font, const QList<Item>& items)
 96void QtFallbackWebPopup::hide()
6597{
66  clear();
 98 m_combo->hidePopup();
 99}
 100
 101void QtFallbackWebPopup::populate()
 102{
 103 m_combo->clear();
67104
68  QStandardItemModel* model = qobject_cast<QStandardItemModel*>(QComboBox::model());
 105 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_combo->model());
69106 Q_ASSERT(model);
70107
71  setFont(font);
72  for (int i = 0; i < items.size(); ++i) {
73  switch (items[i].type) {
74  case QtAbstractWebPopup::Item::Separator:
75  insertSeparator(i);
 108 m_combo->setFont(font());
 109 for (int i = 0; i < itemCount(); ++i) {
 110 switch (itemType(i)) {
 111 case Separator:
 112 m_combo->insertSeparator(i);
76113 break;
77  case QtAbstractWebPopup::Item::Group:
78  insertItem(i, items[i].text);
 114 case Group:
 115 m_combo->insertItem(i, itemText(i));
79116 model->item(i)->setEnabled(false);
80117 break;
81  case QtAbstractWebPopup::Item::Option:
82  insertItem(i, items[i].text);
83  model->item(i)->setEnabled(items[i].enabled);
 118 case Option:
 119 m_combo->insertItem(i, itemText(i));
 120 model->item(i)->setEnabled(itemIsEnabled(i));
84121 break;
85122 }
86123 }
87124}
88125
89 void QtFallbackWebPopup::showPopup()
90 {
91  QComboBox::showPopup();
92  m_popupVisible = true;
93 }
94 
95 void QtFallbackWebPopup::hidePopup()
96 {
97  QWidget* activeFocus = QApplication::focusWidget();
98  if (activeFocus && activeFocus == view()
99  && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
100  QInputContext* qic = activeFocus->inputContext();
101  if (qic) {
102  qic->reset();
103  qic->setFocusWidget(0);
104  }
105  }
106 
107  QComboBox::hidePopup();
108  if (!m_popupVisible)
109  return;
110 
111  m_popupVisible = false;
112  popupDidHide(true);
113 }
114 
115126void QtFallbackWebPopup::activeChanged(int index)
116127{
117128 if (index < 0)

@@void QtFallbackWebPopup::activeChanged(int index)
120131 valueChanged(index);
121132}
122133
123 void QtFallbackWebPopup::setParent(QWidget* parent)
124 {
125  QComboBox::setParent(parent);
126 }
127 
128134}

WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h

2525
2626namespace WebCore {
2727
28 class QtFallbackWebPopup : private QComboBox, public QtAbstractWebPopup {
 28class QtFallbackWebPopupCombo;
 29
 30class QtFallbackWebPopup : public QObject, public QtAbstractWebPopup {
2931 Q_OBJECT
3032public:
3133 QtFallbackWebPopup();
 34 ~QtFallbackWebPopup();
3235
33  virtual void show(const QRect& geometry, int selectedIndex);
34  virtual void hide() { hidePopup(); }
35  virtual void populate(const QFont& font, const QList<Item>& items);
36  virtual void setParent(QWidget* parent);
 36 virtual void show();
 37 virtual void hide();
3738
3839private slots:
3940 void activeChanged(int);
4041
4142private:
 43 friend class QtFallbackWebPopupCombo;
4244 bool m_popupVisible;
 45 QtFallbackWebPopupCombo* m_combo;
4346
 47 void populate();
 48};
4449
 50class QtFallbackWebPopupCombo : public QComboBox {
 51public:
 52 QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup);
4553 virtual void showPopup();
4654 virtual void hidePopup();
 55
 56private:
 57 QtFallbackWebPopup& m_ownerPopup;
4758};
4859
4960}