WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Custom popups, popup factories and usage example
0001-Qt-Custom-select-popups.patch (text/plain), 27.75 KB, created by
Luiz Agostini
on 2010-01-09 07:43:03 PST
(
hide
)
Description:
Custom popups, popup factories and usage example
Filename:
MIME Type:
Creator:
Luiz Agostini
Created:
2010-01-09 07:43:03 PST
Size:
27.75 KB
patch
obsolete
>From 123f6d3db325f5dae8bbe7d7fa2ab168c04fa4bf Mon Sep 17 00:00:00 2001 >From: Luiz Agostini <luiz.agostini@openbossa.org> >Date: Sat, 9 Jan 2010 12:36:59 -0300 >Subject: [PATCH] [Qt] Custom select popups. > https://bugs.webkit.org/show_bug.cgi?id=33418 > >Reviewed by NOBODY (OOPS!). > >WebCore: > >qwebpopup.cpp added to WebCore.pro. > >* WebCore.pro: > >WebKit/qt: > >Support for combobox popup customizations. > >Combobox popup customization can be made providing an instance of QWebPopupFactory to >QWebPage. The factory will be used to create QWebPopup objects when needed. QWebPopup >class is the base class for custom combobox popups. > >QWebPopupFactory inherited classes must implement method create and return an object >of class QWebPopup. > >QWebPage interface has not been changed. No public API is avaliable to set QWebPage's >factories. To use popup factories file qwebpage_p.h must be included and the factory >can be set through function qtQWebPageSetPopupFactory. > >An usage example is available in QGVLauncher. Option 'Use custom popup' can be >found in effects menu. > >* Api/headers.pri: >* Api/qwebpage.cpp: >(QWebPage::setPopupFactory): >(qt_qwebpage_setPopupFactory): >* Api/qwebpage.h: >* Api/qwebpage_p.h: >* QGVLauncher/QGVLauncher.pro: >* QGVLauncher/main.cpp: >(factory): >(WebPage::WebPage): >(WebPage::setPopupFactory): >(SharedScene::setPopupFactory): >(MainWindow::useCustomPopup): >(MainWindow::useDefaultPopup): >(MainWindow::buildUI): >* WebCoreSupport/ChromeClientQt.cpp: >(WebCore::QWebPopupWrapper::QWebPopupWrapper): >(WebCore::QWebPopupWrapper::~QWebPopupWrapper): >(WebCore::QWebPopupWrapper::show): >(WebCore::QWebPopupWrapper::hide): >(WebCore::QWebPopupWrapper::populate): >(WebCore::QWebPopupWrapper::setParent): >(WebCore::QWebPopupWrapper::getItems): >(WebCore::QWebPopupWrapper::didHide): >(WebCore::QWebPopupWrapper::setIndex): >(WebCore::ChromeClientQt::ChromeClientQt): >(WebCore::ChromeClientQt::createPopup): >* WebCoreSupport/ChromeClientQt.h: >* WebCoreSupport/QtFallbackWebPopup.cpp: >(WebCore::QtFallbackWebPopup::show): >--- > WebCore/ChangeLog | 11 ++ > WebCore/WebCore.pro | 1 + > WebKit/qt/Api/headers.pri | 4 +- > WebKit/qt/Api/qwebpage.cpp | 12 ++ > WebKit/qt/Api/qwebpage.h | 6 + > WebKit/qt/Api/qwebpage_p.h | 2 + > WebKit/qt/Api/qwebpopup.cpp | 45 ++++++++ > WebKit/qt/Api/qwebpopup.h | 69 ++++++++++++ > WebKit/qt/Api/qwebpopup_p.h | 38 ++++++ > WebKit/qt/ChangeLog | 54 +++++++++ > WebKit/qt/QGVLauncher/QGVLauncher.pro | 3 +- > WebKit/qt/QGVLauncher/custompopup.cpp | 137 +++++++++++++++++++++++ > WebKit/qt/QGVLauncher/custompopup.h | 70 ++++++++++++ > WebKit/qt/QGVLauncher/main.cpp | 50 ++++++++- > WebKit/qt/WebCoreSupport/ChromeClientQt.cpp | 96 ++++++++++++++++ > WebKit/qt/WebCoreSupport/ChromeClientQt.h | 3 + > WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp | 8 -- > 17 files changed, 597 insertions(+), 12 deletions(-) > create mode 100644 WebKit/qt/Api/qwebpopup.cpp > create mode 100644 WebKit/qt/Api/qwebpopup.h > create mode 100644 WebKit/qt/Api/qwebpopup_p.h > create mode 100644 WebKit/qt/QGVLauncher/custompopup.cpp > create mode 100644 WebKit/qt/QGVLauncher/custompopup.h > >diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog >index e41b74a..776c87e 100644 >--- a/WebCore/ChangeLog >+++ b/WebCore/ChangeLog >@@ -1,3 +1,14 @@ >+2010-01-09 Luiz Agostini <luiz.agostini@openbossa.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [Qt] Custom select popups. >+ https://bugs.webkit.org/show_bug.cgi?id=33418 >+ >+ qwebpopup.cpp added to WebCore.pro. >+ >+ * WebCore.pro: >+ > 2010-01-08 Adam Barth <abarth@webkit.org> > > Unreviewed. Fix namespace indent for SecurityOrigin.h. >diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro >index 6f03838..695a377 100644 >--- a/WebCore/WebCore.pro >+++ b/WebCore/WebCore.pro >@@ -2472,6 +2472,7 @@ SOURCES += \ > ../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \ > ../WebKit/qt/Api/qwebframe.cpp \ > ../WebKit/qt/Api/qgraphicswebview.cpp \ >+ ../WebKit/qt/Api/qwebpopup.cpp \ > ../WebKit/qt/Api/qwebpage.cpp \ > ../WebKit/qt/Api/qwebview.cpp \ > ../WebKit/qt/Api/qwebelement.cpp \ >diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri >index 1a42597..9270ac7 100644 >--- a/WebKit/qt/Api/headers.pri >+++ b/WebKit/qt/Api/headers.pri >@@ -11,4 +11,6 @@ WEBKIT_API_HEADERS = $$PWD/qwebframe.h \ > $$PWD/qwebpluginfactory.h \ > $$PWD/qwebhistory.h \ > $$PWD/qwebinspector.h \ >- $$PWD/qwebkitversion.h >+ $$PWD/qwebkitversion.h \ >+ $$PWD/qwebpopup.h \ >+ $$PWD/qwebpopup_p.h >diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp >index 2147eab..8027a7a 100644 >--- a/WebKit/qt/Api/qwebpage.cpp >+++ b/WebKit/qt/Api/qwebpage.cpp >@@ -1743,6 +1743,18 @@ QWebPage::~QWebPage() > delete d; > } > >+ >+ >+void QWebPage::setPopupFactory(QWebPopupFactory* factory) >+{ >+ d->chromeClient->m_popupFactory = factory; >+} >+ >+void qt_qwebpage_setPopupFactory(QWebPage* page, QWebPopupFactory* factory) >+{ >+ page->setPopupFactory(factory); >+} >+ > /*! > Returns the main frame of the page. > >diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h >index 4766cbd..6b4b5b8 100644 >--- a/WebKit/qt/Api/qwebpage.h >+++ b/WebKit/qt/Api/qwebpage.h >@@ -49,6 +49,8 @@ class QWebPluginFactory; > class QWebHitTestResult; > class QWebHistoryItem; > >+class QWebPopupFactory; >+ > namespace WebCore { > class ChromeClientQt; > class EditorClientQt; >@@ -363,6 +365,10 @@ private: > friend class WebCore::InspectorClientQt; > friend class WebCore::ResourceHandle; > friend class WebCore::QNetworkReplyHandler; >+ >+ friend void qt_qwebpage_setPopupFactory(QWebPage* page, QWebPopupFactory* factory); >+ >+ void setPopupFactory(QWebPopupFactory*); > }; > > Q_DECLARE_OPERATORS_FOR_FLAGS(QWebPage::FindFlags) >diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h >index dbc981e..1e20660 100644 >--- a/WebKit/qt/Api/qwebpage_p.h >+++ b/WebKit/qt/Api/qwebpage_p.h >@@ -185,4 +185,6 @@ public: > static bool drtRun; > }; > >+QWEBKIT_EXPORT void qt_qwebpage_setPopupFactory(QWebPage* page, QWebPopupFactory* factory); >+ > #endif >diff --git a/WebKit/qt/Api/qwebpopup.cpp b/WebKit/qt/Api/qwebpopup.cpp >new file mode 100644 >index 0000000..104e198 >--- /dev/null >+++ b/WebKit/qt/Api/qwebpopup.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "qwebpopup.h" >+ >+#include "qwebpopup_p.h" >+ >+QWebPopup::QWebPopup() >+ : d(new QWebPopupPrivate()) >+{ >+} >+ >+QWebPopup::~QWebPopup() >+{ >+ delete d; >+} >+ >+void QWebPopup::didHide(bool acceptSuggestions) >+{ >+ Q_ASSERT(d->observer); >+ d->observer->didHide(acceptSuggestions); >+} >+ >+void QWebPopup::setIndex(int index) >+{ >+ Q_ASSERT(d->observer); >+ d->observer->setIndex(index); >+} >diff --git a/WebKit/qt/Api/qwebpopup.h b/WebKit/qt/Api/qwebpopup.h >new file mode 100644 >index 0000000..9396f88 >--- /dev/null >+++ b/WebKit/qt/Api/qwebpopup.h >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef qwebpopup_h >+#define qwebpopup_h >+ >+#include <QString> >+#include <QRect> >+#include <QList> >+#include <QWidget> >+#include "qwebkitglobal.h" >+ >+class QWebPopupPrivate; >+ >+namespace WebCore { >+ class QWebPopupWrapper; >+} >+ >+class QWEBKIT_EXPORT QWebPopup { >+public: >+ struct Item { >+ enum { Option, Group, Separator } type; >+ QString text; >+ QString toolTip; >+ bool enabled; >+ }; >+ >+ QWebPopup(); >+ virtual ~QWebPopup(); >+ >+ virtual void show(const QRect& geometry, int selectedIndex) = 0; >+ virtual void hide() = 0; >+ virtual void populate(const QList<Item>& items) = 0; >+ virtual void setParent(QWidget* parent) = 0; >+ >+protected: >+ void didHide(bool acceptSuggestions); >+ void setIndex(int index); >+ >+private: >+ friend class WebCore::QWebPopupWrapper; >+ QWebPopupPrivate* d; >+}; >+ >+class QWebPopupFactory { >+public: >+ virtual QWebPopup* create() = 0; >+}; >+ >+ >+ >+#endif // qwebpopup_h >diff --git a/WebKit/qt/Api/qwebpopup_p.h b/WebKit/qt/Api/qwebpopup_p.h >new file mode 100644 >index 0000000..fc202fa >--- /dev/null >+++ b/WebKit/qt/Api/qwebpopup_p.h >@@ -0,0 +1,38 @@ >+/* >+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef qwebpopup_p_h >+#define qwebpopup_p_h >+ >+class QWebPopupObserver { >+public: >+ virtual void didHide(bool acceptSuggestions) = 0; >+ virtual void setIndex(int index) = 0; >+}; >+ >+class QWebPopupPrivate { >+public: >+ QWebPopupObserver* observer; >+ >+ QWebPopupPrivate() : observer(0) {} >+}; >+ >+ >+#endif // qwebpopup_p_h >diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog >index c303b43..f32c64b 100644 >--- a/WebKit/qt/ChangeLog >+++ b/WebKit/qt/ChangeLog >@@ -1,3 +1,57 @@ >+2010-01-09 Luiz Agostini <luiz.agostini@openbossa.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [Qt] Custom select popups. >+ https://bugs.webkit.org/show_bug.cgi?id=33418 >+ >+ Support for combobox popup customizations. >+ >+ Combobox popup customization can be made providing an instance of QWebPopupFactory to >+ QWebPage. The factory will be used to create QWebPopup objects when needed. QWebPopup >+ class is the base class for custom combobox popups. >+ >+ QWebPopupFactory inherited classes must implement method create and return an object >+ of class QWebPopup. >+ >+ QWebPage interface has not been changed. No public API is avaliable to set QWebPage's >+ factories. To use popup factories file qwebpage_p.h must be included and the factory >+ can be set through function qtQWebPageSetPopupFactory. >+ >+ An usage example is available in QGVLauncher. Option 'Use custom popup' can be >+ found in effects menu. >+ >+ * Api/headers.pri: >+ * Api/qwebpage.cpp: >+ (QWebPage::setPopupFactory): >+ (qtQWebPageSetPopupFactory): >+ * Api/qwebpage.h: >+ * Api/qwebpage_p.h: >+ * QGVLauncher/QGVLauncher.pro: >+ * QGVLauncher/main.cpp: >+ (factory): >+ (WebPage::WebPage): >+ (WebPage::setPopupFactory): >+ (SharedScene::setPopupFactory): >+ (MainWindow::useCustomPopup): >+ (MainWindow::useDefaultPopup): >+ (MainWindow::buildUI): >+ * WebCoreSupport/ChromeClientQt.cpp: >+ (WebCore::QWebPopupWrapper::QWebPopupWrapper): >+ (WebCore::QWebPopupWrapper::~QWebPopupWrapper): >+ (WebCore::QWebPopupWrapper::show): >+ (WebCore::QWebPopupWrapper::hide): >+ (WebCore::QWebPopupWrapper::populate): >+ (WebCore::QWebPopupWrapper::setParent): >+ (WebCore::QWebPopupWrapper::getItems): >+ (WebCore::QWebPopupWrapper::didHide): >+ (WebCore::QWebPopupWrapper::setIndex): >+ (WebCore::ChromeClientQt::ChromeClientQt): >+ (WebCore::ChromeClientQt::createPopup): >+ * WebCoreSupport/ChromeClientQt.h: >+ * WebCoreSupport/QtFallbackWebPopup.cpp: >+ (WebCore::QtFallbackWebPopup::show): >+ > 2010-01-08 Luiz Agostini <luiz.agostini@openbossa.org> > > Reviewed by Kenneth Rohde Christiansen. >diff --git a/WebKit/qt/QGVLauncher/QGVLauncher.pro b/WebKit/qt/QGVLauncher/QGVLauncher.pro >index 059ec1a..9bdfad9 100644 >--- a/WebKit/qt/QGVLauncher/QGVLauncher.pro >+++ b/WebKit/qt/QGVLauncher/QGVLauncher.pro >@@ -1,5 +1,6 @@ > TEMPLATE = app >-SOURCES += main.cpp >+SOURCES += main.cpp custompopup.cpp >+HEADERS += custompopup.h > CONFIG -= app_bundle > CONFIG += uitools > DESTDIR = ../../../bin >diff --git a/WebKit/qt/QGVLauncher/custompopup.cpp b/WebKit/qt/QGVLauncher/custompopup.cpp >new file mode 100644 >index 0000000..41ab4cf >--- /dev/null >+++ b/WebKit/qt/QGVLauncher/custompopup.cpp >@@ -0,0 +1,137 @@ >+/* >+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "custompopup.h" >+ >+#include <QPropertyAnimation> >+#include <QStandardItemModel> >+ >+CustomListWidget::CustomListWidget() >+{ >+} >+ >+void CustomListWidget::focusOutEvent(QFocusEvent* event) >+{ >+ emit focusOut(); >+ QListWidget::focusOutEvent(event); >+} >+ >+CustomPopup::CustomPopup() >+ : m_animation(0) >+{ >+ connect(&m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemChanged())); >+ connect(&m_list, SIGNAL(focusOut()), this, SLOT(focusOut())); >+} >+ >+CustomPopup::~CustomPopup() >+{ >+} >+ >+void CustomPopup::setParent(QWidget* parent) >+{ >+ m_list.setParent(parent); >+} >+ >+void CustomPopup::show(const QRect& geometry, int selectedIndex) >+{ >+ if (m_animation) >+ m_animation->stop(); >+ >+ m_list.setGeometry(QRect(50, 50, geometry.width(), 250)); >+ m_list.setVisible(true); >+ m_list.setCurrentRow(selectedIndex); >+ >+ QPoint start = QPoint(-m_list.width(), -m_list.height()); >+ QPoint end = geometry.topLeft(); >+ >+ QWidget* parent = m_list.parentWidget(); >+ >+ if (parent) { >+ end.setX(qMin(end.x(), parent->width() - m_list.width())); >+ end.setY(qMin(end.y(), parent->height() - m_list.height())); >+ >+ start.setX(2 * end.x() < parent->width() ? -m_list.width() : parent->width()); >+ start.setY(2 * end.y() < parent->height() ? -m_list.height() : parent->height()); >+ } >+ >+ QPropertyAnimation* animation = new QPropertyAnimation(); >+ animation->setTargetObject(&m_list); >+ animation->setPropertyName("pos"); >+ animation->setEasingCurve(QEasingCurve::OutBounce); >+ animation->setDuration(1000); >+ animation->setStartValue(start); >+ animation->setEndValue(end); >+ >+ m_animation = animation; >+ connect(animation, SIGNAL(finished()), this, SLOT(inAnimationEnd())); >+ m_animation->start(QAbstractAnimation::DeleteWhenStopped); >+ >+} >+ >+void CustomPopup::hide() >+{ >+ if (m_animation) >+ m_animation->stop(); >+ >+ QPropertyAnimation* animation = new QPropertyAnimation; >+ animation->setTargetObject(&m_list); >+ animation->setPropertyName("pos"); >+ animation->setEasingCurve(QEasingCurve::OutCubic); >+ animation->setDuration(500); >+ animation->setEndValue(QPoint(-m_list.width(), -m_list.height())); >+ >+ m_animation = animation; >+ connect(animation, SIGNAL(finished()), this, SLOT(outAnimationEnd())); >+ m_animation->start(QAbstractAnimation::DeleteWhenStopped); >+} >+ >+void CustomPopup::populate(const QList<Item>& items) >+{ >+ >+ m_list.clear(); >+ >+ for (int i = 0; i < items.size(); i++) { >+ if (items[i].type == QWebPopup::Item::Separator) >+ m_list.addItem("--------------"); >+ else { >+ m_list.addItem(items[i].text); >+ } >+ } >+} >+ >+void CustomPopup::inAnimationEnd() >+{ >+ m_animation = 0; >+ m_list.setFocus(); >+} >+ >+void CustomPopup::outAnimationEnd() >+{ >+ m_animation = 0; >+ didHide(true); >+ m_list.setParent(0); >+ m_list.setVisible(false); >+} >+ >+void CustomPopup::itemChanged() >+{ >+ setIndex(m_list.currentIndex().row()); >+ hide(); >+} >diff --git a/WebKit/qt/QGVLauncher/custompopup.h b/WebKit/qt/QGVLauncher/custompopup.h >new file mode 100644 >index 0000000..c43b171 >--- /dev/null >+++ b/WebKit/qt/QGVLauncher/custompopup.h >@@ -0,0 +1,70 @@ >+/* >+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef custompopup_h >+#define custompopup_h >+ >+#include "qwebpopup.h" >+ >+#include <QAbstractAnimation> >+#include <QListWidget> >+ >+class CustomListWidget : public QListWidget { >+ Q_OBJECT >+public: >+ CustomListWidget(); >+ >+signals: >+ void focusOut(); >+ >+protected: >+ virtual void focusOutEvent(QFocusEvent* event); >+}; >+ >+class CustomPopup : public QObject, public QWebPopup { >+ Q_OBJECT >+public: >+ CustomPopup(); >+ ~CustomPopup(); >+ >+ >+ virtual void show(const QRect& geometry, int selectedIndex); >+ virtual void hide(); >+ virtual void populate(const QList<Item>& items); >+ virtual void setParent(QWidget* parent); >+ >+private: >+ CustomListWidget m_list; >+ QList<Item> m_items; >+ QAbstractAnimation* m_animation; >+ >+private slots: >+ void inAnimationEnd(); >+ void outAnimationEnd(); >+ void itemChanged(); >+ void focusOut() { hide(); } >+}; >+ >+class CustomPopupFactory : public QWebPopupFactory { >+public: >+ virtual QWebPopup* create() { return new CustomPopup; } >+}; >+ >+#endif // custompopup_h >diff --git a/WebKit/qt/QGVLauncher/main.cpp b/WebKit/qt/QGVLauncher/main.cpp >index b82347e..16a58ba 100644 >--- a/WebKit/qt/QGVLauncher/main.cpp >+++ b/WebKit/qt/QGVLauncher/main.cpp >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) >+ * Copyright (C) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies) > * Copyright (C) 2006 George Staikos <staikos@kde.org> > * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> > * Copyright (C) 2006 Zack Rusin <zack@kde.org> >@@ -32,6 +32,7 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >+#include "custompopup.h" > #include <QDebug> > #include <QFile> > #include <QGraphicsScene> >@@ -47,6 +48,8 @@ > #include <qwebframe.h> > #include <qgraphicswebview.h> > #include <qwebpage.h> >+#include <qwebpopup.h> >+#include <qwebpopup_p.h> > #include <qwebsettings.h> > #include <qwebview.h> > >@@ -93,6 +96,12 @@ private: > qreal m_yRotation; > }; > >+static QWebPopupFactory* factory() >+{ >+ static QWebPopupFactory* result(new CustomPopupFactory); >+ return result; >+} >+ > class WebPage : public QWebPage { > Q_OBJECT > >@@ -101,9 +110,15 @@ public: > : QWebPage(parent) > { > applyProxy(); >+ setPopupFactory(false); > } > virtual QWebPage* createWindow(QWebPage::WebWindowType); > >+ void setPopupFactory(bool useCustomPopup) >+ { >+ qt_qwebpage_setPopupFactory(this, useCustomPopup ? factory() : 0); >+ } >+ > private: > void applyProxy() > { >@@ -222,6 +237,11 @@ public: > QGraphicsScene* scene() const { return m_scene; } > WebView* webView() const { return m_item; } > >+ void setPopupFactory(bool useCustomPopup) >+ { >+ m_page->setPopupFactory(useCustomPopup); >+ } >+ > private: > QGraphicsScene* m_scene; > WebView* m_item; >@@ -382,6 +402,22 @@ public slots: > view->animatedYFlip(); > } > >+ void useCustomPopup() >+ { >+ m_useCustomPopup->setVisible(false); >+ m_useDefaultPopup->setVisible(true); >+ scene->setPopupFactory(true); >+ m_reload->trigger(); >+ } >+ >+ void useDefaultPopup() >+ { >+ m_useCustomPopup->setVisible(true); >+ m_useDefaultPopup->setVisible(false); >+ scene->setPopupFactory(false); >+ m_reload->trigger(); >+ } >+ > private: > > void loadURL(const QUrl& url) >@@ -404,7 +440,8 @@ private: > QToolBar* bar = addToolBar("Navigation"); > bar->addAction(page->action(QWebPage::Back)); > bar->addAction(page->action(QWebPage::Forward)); >- bar->addAction(page->action(QWebPage::Reload)); >+ m_reload = page->action(QWebPage::Reload); >+ bar->addAction(m_reload); > bar->addAction(page->action(QWebPage::Stop)); > bar->addWidget(urlEdit); > >@@ -428,12 +465,21 @@ private: > fxMenu->addAction("Flip", this, SLOT(flip())); > fxMenu->addAction("Animated Flip", this, SLOT(animatedFlip()), QKeySequence("Ctrl+R")); > fxMenu->addAction("Animated Y-Flip", this, SLOT(animatedYFlip()), QKeySequence("Ctrl+Y")); >+ >+ m_useCustomPopup = fxMenu->addAction("Use custom popup", this, SLOT(useCustomPopup())); >+ m_useDefaultPopup = fxMenu->addAction("Use default popup", this, SLOT(useDefaultPopup())); >+ >+ useDefaultPopup(); > } > > private: > MainView* view; > QExplicitlySharedDataPointer<SharedScene> scene; > >+ QAction* m_useCustomPopup; >+ QAction* m_useDefaultPopup; >+ QAction* m_reload; >+ > QLineEdit* urlEdit; > }; > >diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp >index f62bc86..8aff977 100644 >--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp >+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp >@@ -45,6 +45,8 @@ > #include "qwebpage.h" > #include "qwebpage_p.h" > #include "qwebframe_p.h" >+#include "qwebpopup.h" >+#include "qwebpopup_p.h" > #include "qwebsecurityorigin.h" > #include "qwebsecurityorigin_p.h" > #include "qwebview.h" >@@ -56,8 +58,100 @@ namespace WebCore > { > > >+class QWebPopupWrapper : public QtAbstractWebPopup, private QWebPopupObserver { >+public: >+ QWebPopupWrapper(QWebPopup* popup); >+ ~QWebPopupWrapper(); >+ >+public: // QtAbstractWebPopup >+ virtual void show(const QRect& geometry, int selectedIndex); >+ virtual void hide(); >+ virtual void populate(const QFont& font, const QList<Item>& items); >+ virtual void setParent(QWidget* parent); >+ >+private: >+ QWebPopup* m_popup; >+ >+ QList<QWebPopup::Item> getItems(const QList<Item>& items); >+ >+private: // QWebPopupObserver >+ void didHide(bool acceptSuggestions); >+ void setIndex(int index); >+}; >+ >+QWebPopupWrapper::QWebPopupWrapper(QWebPopup* popup) >+ : m_popup(popup) >+{ >+ Q_ASSERT(m_popup); >+ m_popup->d->observer = this; >+} >+ >+QWebPopupWrapper::~QWebPopupWrapper() >+{ >+ delete m_popup; >+} >+ >+void QWebPopupWrapper::show(const QRect& geometry, int selectedIndex) >+{ >+ m_popup->show(geometry, selectedIndex); >+} >+ >+void QWebPopupWrapper::hide() >+{ >+ m_popup->hide(); >+} >+ >+void QWebPopupWrapper::populate(const QFont& font, const QList<Item>& items) >+{ >+ Q_UNUSED(font); >+ m_popup->populate(getItems(items)); >+} >+ >+void QWebPopupWrapper::setParent(QWidget* parent) >+{ >+ m_popup->setParent(parent); >+} >+ >+QList<QWebPopup::Item> QWebPopupWrapper::getItems(const QList<Item>& items) >+{ >+ QList<QWebPopup::Item> result; >+ >+ for (int i = 0; i < items.size(); ++i) { >+ QWebPopup::Item item; >+ >+ switch (items[i].type) { >+ case Item::Option: >+ item.type = QWebPopup::Item::Option; >+ case Item::Separator: >+ item.type = QWebPopup::Item::Separator; >+ case Item::Group: >+ item.type = QWebPopup::Item::Group; >+ } >+ >+ item.text = items[i].text; >+ item.toolTip = items[i].toolTip; >+ item.enabled = items[i].enabled; >+ >+ result.append(item); >+ } >+ >+ return result; >+} >+ >+void QWebPopupWrapper::didHide(bool acceptSuggestions) >+{ >+ popupDidHide(acceptSuggestions); >+} >+ >+void QWebPopupWrapper::setIndex(int index) >+{ >+ valueChanged(index); >+} >+ >+ > ChromeClientQt::ChromeClientQt(QWebPage* webPage) > : m_webPage(webPage) >+ , m_popupFactory(0) > { > toolBarsVisible = statusBarVisible = menuBarVisible = true; > } >@@ -468,6 +562,8 @@ void ChromeClientQt::requestGeolocationPermissionForFrame(Frame*, Geolocation*) > > QtAbstractWebPopup* ChromeClientQt::createPopup() > { >+ if (m_popupFactory) >+ return new QWebPopupWrapper(m_popupFactory->create()); > return new QtFallbackWebPopup; > } > >diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h >index 106d4cc..16a695b 100644 >--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h >+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h >@@ -35,6 +35,7 @@ > #include "PlatformString.h" > > class QWebPage; >+class QWebPopupFactory; > > namespace WebCore { > >@@ -145,6 +146,8 @@ namespace WebCore { > bool toolBarsVisible; > bool statusBarVisible; > bool menuBarVisible; >+ >+ QWebPopupFactory* m_popupFactory; > }; > } > >diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp >index 344d58a..f0e76e6 100644 >--- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp >+++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp >@@ -46,14 +46,6 @@ void QtFallbackWebPopup::show(const QRect& geometry, int selectedIndex) > { > setCurrentIndex(selectedIndex); > >- /* >- QWidget* parent = 0; >- if (client()->hostWindow() && client()->hostWindow()->platformPageClient()) >- parent = client()->hostWindow()->platformPageClient()->ownerWidget(); >- >- setParent(parent); >- */ >- > setGeometry(QRect(geometry.left(), geometry.top(), geometry.width(), sizeHint().height())); > > QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton, >-- >1.6.3.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 33418
:
46206
|
46208
|
46209
|
46653
|
46845
|
46855
|
46894
|
47020
|
47022