diff options
Diffstat (limited to 'WebKit/qt')
34 files changed, 901 insertions, 343 deletions
diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 53c1494..47ab82a 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -241,7 +241,7 @@ QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) : QGraphicsWidget(parent) , d(new QGraphicsWebViewPrivate(this)) { -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); #endif setAcceptDrops(true); @@ -417,7 +417,7 @@ void QGraphicsWebViewPrivate::detachCurrentPage() if (!page) return; -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) page->d->view.clear(); #else page->d->view = 0; diff --git a/WebKit/qt/Api/qwebdatabase_p.h b/WebKit/qt/Api/qwebdatabase_p.h index 9ae8fc8..ec03ea5 100644 --- a/WebKit/qt/Api/qwebdatabase_p.h +++ b/WebKit/qt/Api/qwebdatabase_p.h @@ -29,7 +29,7 @@ class QWebDatabasePrivate : public QSharedData { public: - WebCore::String name; + WTF::String name; WTF::RefPtr<WebCore::SecurityOrigin> origin; }; diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index e90367e..0bb6922 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -36,6 +36,7 @@ #include "GraphicsContext.h" #include "HTMLMetaElement.h" #include "HitTestResult.h" +#include "HTTPParsers.h" #include "IconDatabase.h" #include "InspectorController.h" #include "JSDOMBinding.h" @@ -178,7 +179,7 @@ void QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int d QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame, WebCore::HTMLFrameOwnerElement* ownerFrameElement, - const WebCore::String& frameName) + const WTF::String& frameName) : name(frameName) , ownerElement(ownerFrameElement) , page(parentPage) @@ -753,7 +754,7 @@ void QWebFrame::load(const QNetworkRequest &req, case QNetworkAccessManager::PostOperation: request.setHTTPMethod("POST"); break; -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) case QNetworkAccessManager::DeleteOperation: request.setHTTPMethod("DELETE"); break; @@ -808,7 +809,7 @@ void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl) WebCore::ResourceRequest request(kurl); const QByteArray utf8 = html.toUtf8(); WTF::RefPtr<WebCore::SharedBuffer> data = WebCore::SharedBuffer::create(utf8.constData(), utf8.length()); - WebCore::SubstituteData substituteData(data, WebCore::String("text/html"), WebCore::String("utf-8"), KURL()); + WebCore::SubstituteData substituteData(data, WTF::String("text/html"), WTF::String("utf-8"), KURL()); d->frame->loader()->load(request, substituteData, false); } @@ -830,10 +831,15 @@ void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, cons KURL kurl(baseUrl); WebCore::ResourceRequest request(kurl); WTF::RefPtr<WebCore::SharedBuffer> buffer = WebCore::SharedBuffer::create(data.constData(), data.length()); - QString actualMimeType = mimeType; - if (actualMimeType.isEmpty()) + QString actualMimeType; + WTF::String encoding; + if (mimeType.isEmpty()) actualMimeType = QLatin1String("text/html"); - WebCore::SubstituteData substituteData(buffer, WebCore::String(actualMimeType), WebCore::String(), KURL()); + else { + actualMimeType = extractMIMETypeFromMediaType(mimeType); + encoding = extractCharsetFromMediaType(mimeType); + } + WebCore::SubstituteData substituteData(buffer, WTF::String(actualMimeType), encoding, KURL()); d->frame->loader()->load(request, substituteData, false); } diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index 62bd59e..15b0549 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -44,16 +44,16 @@ class QWebFrameData { public: QWebFrameData(WebCore::Page*, WebCore::Frame* parentFrame = 0, WebCore::HTMLFrameOwnerElement* = 0, - const WebCore::String& frameName = WebCore::String()); + const WTF::String& frameName = WTF::String()); WebCore::KURL url; - WebCore::String name; + WTF::String name; WebCore::HTMLFrameOwnerElement* ownerElement; WebCore::Page* page; RefPtr<WebCore::Frame> frame; WebCore::FrameLoaderClientQt* frameLoaderClient; - WebCore::String referrer; + WTF::String referrer; bool allowsScrolling; int marginWidth; int marginHeight; diff --git a/WebKit/qt/Api/qwebkitplatformplugin.h b/WebKit/qt/Api/qwebkitplatformplugin.h index 32d22d4..3c56c98 100644 --- a/WebKit/qt/Api/qwebkitplatformplugin.h +++ b/WebKit/qt/Api/qwebkitplatformplugin.h @@ -81,6 +81,20 @@ Q_SIGNALS: void notificationClosed(); }; +class QWebHapticFeedbackPlayer +{ +public: + enum HapticStrength { + None, Weak, Medium, Strong + }; + + enum HapticEvent { + Press, Release + }; + + virtual void playHapticFeedback(const HapticEvent, const QString& hapticType, const HapticStrength) = 0; +}; + class QWebKitPlatformPlugin { public: @@ -88,15 +102,17 @@ public: enum Extension { MultipleSelections, - Notifications + Notifications, + Haptics }; virtual bool supportsExtension(Extension extension) const = 0; virtual QWebSelectMethod* createSelectInputMethod() const = 0; virtual QWebNotificationPresenter* createNotificationPresenter() const = 0; + virtual QWebHapticFeedbackPlayer* createHapticFeedbackPlayer() const = 0; }; -Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.2"); +Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.3"); #endif // QWEBKITPLATFORMPLUGIN_H diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index a8bd06a..516ebc9 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -252,7 +252,7 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions) QWebPagePrivate::QWebPagePrivate(QWebPage *qq) : q(qq) , client(0) -#if QT_VERSION < 0x040600 +#if QT_VERSION < QT_VERSION_CHECK(4, 6, 0) , view(0) #endif , clickCausedFocus(false) @@ -1131,7 +1131,7 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) { WebCore::Frame *frame = page->focusController()->focusedOrMainFrame(); WebCore::Editor *editor = frame->editor(); -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QInputMethodEvent::Attribute selection(QInputMethodEvent::Selection, 0, 0, QVariant()); #endif @@ -1172,7 +1172,7 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) } break; } -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) case QInputMethodEvent::Selection: { selection = a; hasSelection = true; @@ -1190,7 +1190,7 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) // 3. populated preedit with a selection attribute, and start/end of 0 or non-0 updates selection of supplied preedit text // 4. otherwise event is updating supplied pre-edit text QString preedit = ev->preeditString(); -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) if (hasSelection) { QString text = (renderTextControl) ? QString(renderTextControl->text()) : QString(); if (preedit.isEmpty() && selection.start + selection.length > 0) @@ -1473,7 +1473,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const return QVariant(); } -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) case Qt::ImAnchorPosition: { if (renderTextControl) { if (editor->hasComposition()) { @@ -1978,7 +1978,7 @@ void QWebPage::setView(QWidget* view) */ QWidget *QWebPage::view() const { -#if QT_VERSION < 0x040600 +#if QT_VERSION < QT_VERSION_CHECK(4, 6, 0) return d->view; #else return d->view.data(); diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index f0d2438..14f3b8b 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -217,6 +217,7 @@ public: inline qreal initialScaleFactor() const { return m_initialScaleFactor; }; inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; }; inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; }; + inline int targetDensityDpi() const { return m_targetDensityDpi; }; inline bool isUserScalable() const { return m_isUserScalable; }; inline bool isValid() const { return m_isValid; }; inline QSize size() const { return m_size; }; @@ -226,6 +227,7 @@ public: qreal m_initialScaleFactor; qreal m_minimumScaleFactor; qreal m_maximumScaleFactor; + int m_targetDensityDpi; bool m_isUserScalable; bool m_isValid; QSize m_size; diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index 773c79a..5e7265f 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -349,7 +349,7 @@ void QWebViewPrivate::detachCurrentPage() return; if (page) { -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) page->d->view.clear(); #else page->d->view = 0; diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index b49385a..4f2845f 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,226 @@ +2010-08-06 Gavin Barraclough <barraclough@apple.com> + + Rubber stamped by Sam Weinig + + Bug 43594 - Add string forwards to Forward.h + This allows us to remove forward declarations for these classes from + WebCore/WebKit (a step in moving these class from WebCore:: to WTF::). + + * WebCoreSupport/FrameLoaderClientQt.h: + * WebCoreSupport/InspectorClientQt.h: + +2010-08-08 Ariya Hidayat <ariya@sencha.com> + + Reviewed by Antonio Gomes. + + Inconsistent Qt version checks + https://bugs.webkit.org/show_bug.cgi?id=43695 + + Use QT_VERSION_CHECK macro instead of encoded hex. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::QGraphicsWebView): + (QGraphicsWebViewPrivate::detachCurrentPage): + * Api/qwebframe.cpp: + (QWebFrame::load): + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + (QWebPagePrivate::inputMethodEvent): + (QWebPage::inputMethodQuery): + (QWebPage::view): + * Api/qwebview.cpp: + (QWebViewPrivate::detachCurrentPage): + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::createPlugin): + * WebCoreSupport/PageClientQt.cpp: + * WebCoreSupport/PageClientQt.h: + +2010-08-06 Jessie Berlin <jberlin@apple.com> + + Roll out http://trac.webkit.org/changeset/64801, which broke the Safari Windows Build. + Unreviewed. + + * WebCoreSupport/FrameLoaderClientQt.h: + * WebCoreSupport/InspectorClientQt.h: + +2010-08-06 Luiz Agostini <luiz.agostini@openbossa.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Move Qt's popup menu implementation from WebCore to WebKit layer + https://bugs.webkit.org/show_bug.cgi?id=43427 + + After PopupMenu changes in bug 42592 class QtAbstractWebPopup became unecessary and + there is no need to keep any Qt specific code for popup menus in WebCore/platform/qt. + + PopupMenuQt has been moved from WebCore/platform/qt to WebKit/qt/WebCoreSupport and + assumed the responsibilities of QtAbstractWebPopup. SearchPopupMenuQt has been moved + to WebKit/qt/WebCoreSupport as well. + + All classes that previously inherited from QtAbstractWebPopup now inherit from + QWebSelectMethod and QtPlatformPlugin's method createSelectInputMethod now returns an + instance of class QWebSelectMethod instead of QtAbstractWebPopup. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::createSelectPopup): + (WebCore::ChromeClientQt::createPopupMenu): + (WebCore::ChromeClientQt::createSearchPopupMenu): + * WebCoreSupport/ChromeClientQt.h: + * WebCoreSupport/PopupMenuQt.cpp: Added. + (SelectData::SelectData): + (SelectData::itemText): + (SelectData::itemToolTip): + (SelectData::itemIsEnabled): + (SelectData::itemCount): + (SelectData::itemIsSelected): + (SelectData::multiple): + (SelectData::itemType): + (WebCore::PopupMenuQt::PopupMenuQt): + (WebCore::PopupMenuQt::~PopupMenuQt): + (WebCore::PopupMenuQt::disconnectClient): + (WebCore::PopupMenuQt::show): + (WebCore::PopupMenuQt::didHide): + (WebCore::PopupMenuQt::hide): + (WebCore::PopupMenuQt::updateFromElement): + (WebCore::PopupMenuQt::selectItem): + * WebCoreSupport/PopupMenuQt.h: Added. + * WebCoreSupport/QtFallbackWebPopup.cpp: + (WebCore::QtFallbackWebPopupCombo::hidePopup): + (WebCore::QtFallbackWebPopup::QtFallbackWebPopup): + (WebCore::QtFallbackWebPopup::show): + (WebCore::QtFallbackWebPopup::populate): + (WebCore::QtFallbackWebPopup::activeChanged): + (WebCore::QtFallbackWebPopup::pageClient): + * WebCoreSupport/QtFallbackWebPopup.h: + (WebCore::QtFallbackWebPopup::setGeometry): + (WebCore::QtFallbackWebPopup::geometry): + (WebCore::QtFallbackWebPopup::setFont): + (WebCore::QtFallbackWebPopup::font): + * WebCoreSupport/QtMaemoWebPopup.cpp: + (WebCore::Maemo5Popup::populateList): + (WebCore::QtMaemoWebPopup::QtMaemoWebPopup): + (WebCore::QtMaemoWebPopup::createSingleSelectionPopup): + (WebCore::QtMaemoWebPopup::createMultipleSelectionPopup): + (WebCore::QtMaemoWebPopup::createPopup): + (WebCore::QtMaemoWebPopup::show): + (WebCore::QtMaemoWebPopup::popupClosed): + (WebCore::QtMaemoWebPopup::itemClicked): + (WebCore::Maemo5SingleSelectionPopup::Maemo5SingleSelectionPopup): + (WebCore::Maemo5MultipleSelectionPopup::Maemo5MultipleSelectionPopup): + * WebCoreSupport/QtMaemoWebPopup.h: + (WebCore::Maemo5Popup::Maemo5Popup): + * WebCoreSupport/QtPlatformPlugin.cpp: + (WebCore::QtPlatformPlugin::createSelectInputMethod): + * WebCoreSupport/QtPlatformPlugin.h: + * WebCoreSupport/SearchPopupMenuQt.cpp: Added. + (WebCore::SearchPopupMenuQt::SearchPopupMenuQt): + (WebCore::SearchPopupMenuQt::popupMenu): + (WebCore::SearchPopupMenuQt::saveRecentSearches): + (WebCore::SearchPopupMenuQt::loadRecentSearches): + (WebCore::SearchPopupMenuQt::enabled): + * WebCoreSupport/SearchPopupMenuQt.h: Added. + +2010-08-06 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Antonio Gomes. + + [Qt] Add support for the Android viewport meta tag extensions. + http://webkit.org/b/43567 + + * Api/qwebpage.h: + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::didReceiveViewportArguments): + +2010-08-05 Gavin Barraclough <barraclough@apple.com> + + Rubber stamped by Sam Weinig + + Bug 43594 - Add string forwards to Forward.h + This allows us to remove forward declarations for these classes from + WebCore/WebKit (a step in moving these class from WebCore:: to WTF::). + + * WebCoreSupport/FrameLoaderClientQt.h: + * WebCoreSupport/InspectorClientQt.h: + +2010-08-05 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Clean up the input method handling + https://bugs.webkit.org/show_bug.cgi?id=43545 + + Replace the way of individually setting input method hints by + many calls to QWidget::setInputMethodHints with one single call. + + This is more efficient by requiring less updates in the input + method hint. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + * WebCoreSupport/PageClientQt.cpp: + (WebCore::PageClientQWidget::setInputMethodHints): + (WebCore::PageClientQGraphicsWidget::setInputMethodHints): + * WebCoreSupport/PageClientQt.h: + +2010-08-05 David Leong <david.leong@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Input mode states are not reset after entering a password field + https://bugs.webkit.org/show_bug.cgi?id=43530 + + Input mode hints are not reset if clicking on password <input> elements then + clicking on <textarea> elements + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + * tests/qwebview/resources/input_types.html: + * tests/qwebview/tst_qwebview.cpp: + (tst_QWebView::focusInputTypes): + + +2010-08-04 Pierre Rossi <pierre.rossi@nokia.com> + + Reviewed by Antonio Gomes. + + [Qt] QWebFrame::setContent() does not respect charset provided in the mimeType + https://bugs.webkit.org/show_bug.cgi?id=43125 + + * Api/qwebframe.cpp: + (QWebFrame::setContent): + * tests/qwebframe/tst_qwebframe.cpp: + +2010-08-03 Noam Rosenthal <noam.rosenthal@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Edits to bridge documentation + https://bugs.webkit.org/show_bug.cgi?id=43012 + + * docs/qtwebkit-bridge.qdoc: + * docs/webkitsnippets/qtwebkit_bridge_snippets.cpp: + (wrapInFunction): + +2010-08-03 Kim Grönholm <kim.1.gronholm@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Platform plugin interface for Haptics + https://bugs.webkit.org/show_bug.cgi?id=43143 + + Platform plugin interface for playing haptic feedback + + * Api/qwebkitplatformplugin.h: + (QWebHapticFeedbackPlayer::): + (QWebKitPlatformPlugin::): + * examples/platformplugin/WebPlugin.h: + (WebPlugin::createHapticFeedbackPlayer): + * examples/platformplugin/qwebkitplatformplugin.h: + (QWebHapticFeedbackPlayer::): + (QWebKitPlatformPlugin::): + 2010-07-27 Luiz Agostini <luiz.agostini@openbossa.org> Reviewed by Darin Fisher. diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index a0bac72..0b77ea6 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -591,16 +591,16 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const } #endif -QtAbstractWebPopup* ChromeClientQt::createSelectPopup() +QWebSelectMethod* ChromeClientQt::createSelectPopup() const { - QtAbstractWebPopup* result = m_platformPlugin.createSelectInputMethod(); + QWebSelectMethod* result = m_platformPlugin.createSelectInputMethod(); if (result) return result; #if defined(Q_WS_MAEMO_5) return new QtMaemoWebPopup; #elif !defined(QT_NO_COMBOBOX) - return new QtFallbackWebPopup; + return new QtFallbackWebPopup(this); #else return 0; #endif @@ -620,6 +620,7 @@ void ChromeClientQt::didReceiveViewportArguments(Frame* frame, const ViewportArg hints.m_initialScaleFactor = arguments.initialScale; hints.m_minimumScaleFactor = arguments.minimumScale; hints.m_maximumScaleFactor = arguments.maximumScale; + hints.m_targetDensityDpi = arguments.targetDensityDpi; hints.m_isUserScalable = isUserScalable; emit m_webPage->viewportChangeRequested(hints); @@ -632,12 +633,12 @@ bool ChromeClientQt::selectItemWritingDirectionIsNatural() PassRefPtr<PopupMenu> ChromeClientQt::createPopupMenu(PopupMenuClient* client) const { - return adoptRef(new PopupMenuQt(client)); + return adoptRef(new PopupMenuQt(client, this)); } PassRefPtr<SearchPopupMenu> ChromeClientQt::createSearchPopupMenu(PopupMenuClient* client) const { - return adoptRef(new SearchPopupMenuQt(client)); + return adoptRef(new SearchPopupMenuQt(createPopupMenu(client))); } } // namespace WebCore diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h index aab2813..55edc50 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -174,21 +174,21 @@ namespace WebCore { virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const; - QtAbstractWebPopup* createSelectPopup(); + QWebSelectMethod* createSelectPopup() const; virtual void didReceiveViewportArguments(Frame*, const ViewportArguments&) const; QWebPage* m_webPage; WebCore::KURL lastHoverURL; - WebCore::String lastHoverTitle; - WebCore::String lastHoverContent; + WTF::String lastHoverTitle; + WTF::String lastHoverContent; bool toolBarsVisible; bool statusBarVisible; bool menuBarVisible; QEventLoop* m_eventLoop; - QtPlatformPlugin m_platformPlugin; + mutable QtPlatformPlugin m_platformPlugin; }; } diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 54993b1..0a9a0ea 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -595,7 +595,9 @@ void EditorClientQt::setInputMethodState(bool active) { QWebPageClient* webPageClient = m_page->d->client; if (webPageClient) { -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + Qt::InputMethodHints hints; + HTMLInputElement* inputElement = 0; Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); if (frame && frame->document() && frame->document()->focusedNode()) @@ -604,24 +606,29 @@ void EditorClientQt::setInputMethodState(bool active) if (inputElement) { // Set input method hints for "number", "tel", "email", "url" and "password" input elements. - webPageClient->setInputMethodHint(Qt::ImhDialableCharactersOnly, inputElement->isTelephoneField()); - webPageClient->setInputMethodHint(Qt::ImhDigitsOnly, inputElement->isNumberField()); - webPageClient->setInputMethodHint(Qt::ImhEmailCharactersOnly, inputElement->isEmailField()); - webPageClient->setInputMethodHint(Qt::ImhUrlCharactersOnly, inputElement->isUrlField()); + if (inputElement->isTelephoneField()) + hints |= Qt::ImhDialableCharactersOnly; + if (inputElement->isNumberField()) + hints |= Qt::ImhDigitsOnly; + if (inputElement->isEmailField()) + hints |= Qt::ImhEmailCharactersOnly; + if (inputElement->isUrlField()) + hints |= Qt::ImhUrlCharactersOnly; // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag // for password fields. The Qt platform is responsible for determining which widget // will receive input method events for password fields. - bool isPasswordField = inputElement->isPasswordField(); - webPageClient->setInputMethodHint(Qt::ImhHiddenText, isPasswordField); - if (isPasswordField) + if (inputElement->isPasswordField()) { active = true; + hints |= Qt::ImhHiddenText; + } } #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) // disables auto-uppercase and predictive text for mobile devices - webPageClient->setInputMethodHint(Qt::ImhNoAutoUppercase, true); - webPageClient->setInputMethodHint(Qt::ImhNoPredictiveText, true); + hints |= Qt::ImhNoAutoUppercase; + hints |= Qt::ImhNoPredictiveText; #endif // Q_WS_MAEMO_5 || Q_WS_MAEMO_6 || Q_OS_SYMBIAN + webPageClient->setInputMethodHints(hints); #endif // QT_VERSION check webPageClient->setInputMethodEnabled(active); } diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 9fe66d9..cf76dae 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -1067,7 +1067,7 @@ WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage() return newPage->mainFrame()->d->frame; } -void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&) +void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WTF::String& MIMEType, const WebCore::ResourceRequest&) { // we need to call directly here const ResourceResponse& response = m_frame->loader()->activeDocumentLoader()->response(); @@ -1079,7 +1079,7 @@ void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction fu callPolicyFunction(function, PolicyDownload); } -void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>, const WebCore::String&) +void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>, const WTF::String&) { Q_ASSERT(m_webFrame); QNetworkRequest r(request.toNetworkRequest(m_webFrame)); @@ -1321,7 +1321,7 @@ private: } }; -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) class QtPluginGraphicsWidget: public Widget { public: @@ -1439,7 +1439,7 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, w->setFrameRect(IntRect(0, 0, 0, 0)); return w; } -#if QT_VERSION >= 0x040600 +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object); if (graphicsWidget) { QGraphicsObject* parentWidget = 0; diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h index ec672f5..00a073f 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h @@ -40,6 +40,7 @@ #include "ResourceResponse.h" #include <QUrl> #include <qobject.h> +#include <wtf/Forward.h> class QWebFrame; namespace WebCore { @@ -49,7 +50,6 @@ class DocumentLoader; class Element; class FormState; class NavigationAction; -class String; class ResourceLoader; struct LoadErrorResetToken; @@ -121,8 +121,8 @@ public: virtual WebCore::Frame* dispatchCreatePage(); virtual void dispatchShow(); - virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String&, const WebCore::ResourceRequest&); - virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, const WebCore::String&); + virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WTF::String&, const WebCore::ResourceRequest&); + virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, const WTF::String&); virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>); virtual void cancelPolicyCheck(); diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h index c996f55..9526c88 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h @@ -35,6 +35,7 @@ #include "OwnPtr.h" #include "PassOwnPtr.h" #include <QtCore/QString> +#include <wtf/Forward.h> class QWebPage; class QWebView; @@ -42,7 +43,6 @@ class QWebView; namespace WebCore { class Node; class Page; -class String; class InspectorClientQt : public InspectorClient { public: diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.cpp b/WebKit/qt/WebCoreSupport/PageClientQt.cpp index 90a5a63..62f48ff 100644 --- a/WebKit/qt/WebCoreSupport/PageClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/PageClientQt.cpp @@ -48,13 +48,10 @@ bool PageClientQWidget::inputMethodEnabled() const return view->testAttribute(Qt::WA_InputMethodEnabled); } -#if QT_VERSION >= 0x040600 -void PageClientQWidget::setInputMethodHint(Qt::InputMethodHint hint, bool enable) +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) +void PageClientQWidget::setInputMethodHints(Qt::InputMethodHints hints) { - if (enable) - view->setInputMethodHints(view->inputMethodHints() | hint); - else - view->setInputMethodHints(view->inputMethodHints() & ~hint); + view->setInputMethodHints(hints); } #endif @@ -232,13 +229,10 @@ bool PageClientQGraphicsWidget::inputMethodEnabled() const #endif } -#if QT_VERSION >= 0x040600 -void PageClientQGraphicsWidget::setInputMethodHint(Qt::InputMethodHint hint, bool enable) +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) +void PageClientQGraphicsWidget::setInputMethodHints(Qt::InputMethodHints hints) { - if (enable) - view->setInputMethodHints(view->inputMethodHints() | hint); - else - view->setInputMethodHints(view->inputMethodHints() & ~hint); + view->setInputMethodHints(hints); } #endif diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.h b/WebKit/qt/WebCoreSupport/PageClientQt.h index 1204afc..65ee849 100644 --- a/WebKit/qt/WebCoreSupport/PageClientQt.h +++ b/WebKit/qt/WebCoreSupport/PageClientQt.h @@ -58,8 +58,8 @@ public: virtual void update(const QRect& dirtyRect); virtual void setInputMethodEnabled(bool enable); virtual bool inputMethodEnabled() const; -#if QT_VERSION >= 0x040600 - virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + virtual void setInputMethodHints(Qt::InputMethodHints hints); #endif #ifndef QT_NO_CURSOR @@ -146,8 +146,8 @@ public: virtual void update(const QRect& dirtyRect); virtual void setInputMethodEnabled(bool enable); virtual bool inputMethodEnabled() const; -#if QT_VERSION >= 0x040600 - virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); +#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) + virtual void setInputMethodHints(Qt::InputMethodHints hints); #endif #ifndef QT_NO_CURSOR diff --git a/WebKit/qt/WebCoreSupport/PopupMenuQt.cpp b/WebKit/qt/WebCoreSupport/PopupMenuQt.cpp new file mode 100644 index 0000000..56a0fac --- /dev/null +++ b/WebKit/qt/WebCoreSupport/PopupMenuQt.cpp @@ -0,0 +1,158 @@ +/* + * This file is part of the popup menu implementation for <select> elements in WebCore. + * + * Copyright (C) 2008, 2009, 2010 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Coypright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> + * + * 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 "config.h" +#include "PopupMenuQt.h" + +#include "ChromeClientQt.h" +#include "FrameView.h" +#include "PopupMenuClient.h" +#include "QtFallbackWebPopup.h" + +#include "qwebkitplatformplugin.h" + +class SelectData : public QWebSelectData { +public: + SelectData(WebCore::PopupMenuClient*& data) : d(data) {} + + virtual ItemType itemType(int) const; + virtual QString itemText(int idx) const { return QString(d ? d->itemText(idx) : ""); } + virtual QString itemToolTip(int idx) const { return QString(d ? d->itemToolTip(idx) : ""); } + virtual bool itemIsEnabled(int idx) const { return d ? d->itemIsEnabled(idx) : false; } + virtual int itemCount() const { return d ? d->listSize() : 0; } + virtual bool itemIsSelected(int idx) const { return d ? d->itemIsSelected(idx) : false; } + virtual bool multiple() const; + +private: + WebCore::PopupMenuClient*& d; +}; + +bool SelectData::multiple() const +{ + if (!d) + return false; + +#if ENABLE(NO_LISTBOX_RENDERING) + WebCore::ListPopupMenuClient* client = static_cast<WebCore::ListPopupMenuClient*>(d); + return client && client->multiple(); +#else + return false; +#endif +} + +SelectData::ItemType SelectData::itemType(int idx) const +{ + if (!d) + return SelectData::Option; + + if (d->itemIsSeparator(idx)) + return SelectData::Separator; + if (d->itemIsLabel(idx)) + return SelectData::Group; + return SelectData::Option; +} + +namespace WebCore { + +PopupMenuQt::PopupMenuQt(PopupMenuClient* client, const ChromeClientQt* chromeClient) + : m_popupClient(client) + , m_popup(0) + , m_selectData(0) + , m_chromeClient(chromeClient) +{ +} + +PopupMenuQt::~PopupMenuQt() +{ + delete m_selectData; + delete m_popup; +} + +void PopupMenuQt::disconnectClient() +{ + m_popupClient = 0; +} + +void PopupMenuQt::show(const IntRect& rect, FrameView* view, int index) +{ + if (!m_popupClient) + return; + + if (!m_popup) { + m_popup = m_chromeClient->createSelectPopup(); + connect(m_popup, SIGNAL(didHide()), this, SLOT(didHide())); + connect(m_popup, SIGNAL(selectItem(int, bool, bool)), this, SLOT(selectItem(int, bool, bool))); + } + + if (QtFallbackWebPopup* fallback = qobject_cast<QtFallbackWebPopup*>(m_popup)) { + QRect geometry(rect); + geometry.moveTopLeft(view->contentsToWindow(rect.topLeft())); + fallback->setGeometry(geometry); + fallback->setFont(m_popupClient->menuStyle().font().font()); + } + + if (m_selectData) + delete m_selectData; + m_selectData = new SelectData(m_popupClient); + m_popup->show(*m_selectData); +} + +void PopupMenuQt::didHide() +{ + if (m_popupClient) + m_popupClient->popupDidHide(); +} + +void PopupMenuQt::hide() +{ + if (!m_popup) + m_popup->hide(); +} + +void PopupMenuQt::updateFromElement() +{ + if (m_popupClient) + m_popupClient->setTextFromItem(m_popupClient->selectedIndex()); +} + +void PopupMenuQt::selectItem(int index, bool ctrl, bool shift) +{ + if (!m_popupClient) + return; + +#if ENABLE(NO_LISTBOX_RENDERING) + ListPopupMenuClient* client = static_cast<ListPopupMenuClient*>(m_popupClient); + if (client) { + client->listBoxSelectItem(index, ctrl, shift); + return; + } +#endif + + m_popupClient->valueChanged(index); +} + +} + +// vim: ts=4 sw=4 et diff --git a/WebKit/qt/WebCoreSupport/PopupMenuQt.h b/WebKit/qt/WebCoreSupport/PopupMenuQt.h new file mode 100644 index 0000000..837f323 --- /dev/null +++ b/WebKit/qt/WebCoreSupport/PopupMenuQt.h @@ -0,0 +1,59 @@ +/* + * 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 PopupMenuQt_h +#define PopupMenuQt_h + +#include "PopupMenu.h" +#include <QObject> + +class QWebSelectData; +class QWebSelectMethod; + +namespace WebCore { + +class ChromeClientQt; +class FrameView; +class PopupMenuClient; + +class PopupMenuQt : public QObject, public PopupMenu { + Q_OBJECT +public: + PopupMenuQt(PopupMenuClient*, const ChromeClientQt*); + ~PopupMenuQt(); + + virtual void show(const IntRect&, FrameView*, int index); + virtual void hide(); + virtual void updateFromElement(); + virtual void disconnectClient(); + +private slots: + void didHide(); + void selectItem(int index, bool ctrl, bool shift); + +private: + PopupMenuClient* m_popupClient; + QWebSelectMethod* m_popup; + QWebSelectData* m_selectData; + const ChromeClientQt* m_chromeClient; +}; + +} + +#endif // PopupMenuQt_h diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp index 59ac87b..21678c7 100644 --- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp +++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp @@ -23,8 +23,7 @@ #ifndef QT_NO_COMBOBOX -#include "HostWindow.h" -#include "PopupMenuClient.h" +#include "ChromeClientQt.h" #include "QWebPageClient.h" #include "qgraphicswebview.h" #include <QAbstractItemView> @@ -79,7 +78,7 @@ void QtFallbackWebPopupCombo::hidePopup() return; m_ownerPopup.m_popupVisible = false; - m_ownerPopup.popupDidHide(); + emit m_ownerPopup.didHide(); m_ownerPopup.destroyPopup(); } @@ -97,10 +96,10 @@ bool QtFallbackWebPopupCombo::eventFilter(QObject* watched, QEvent* event) // QtFallbackWebPopup -QtFallbackWebPopup::QtFallbackWebPopup() - : QtAbstractWebPopup() - , m_popupVisible(false) +QtFallbackWebPopup::QtFallbackWebPopup(const ChromeClientQt* chromeClient) + : m_popupVisible(false) , m_combo(0) + , m_chromeClient(chromeClient) { } @@ -109,7 +108,7 @@ QtFallbackWebPopup::~QtFallbackWebPopup() destroyPopup(); } -void QtFallbackWebPopup::show() +void QtFallbackWebPopup::show(const QWebSelectData& data) { if (!pageClient()) return; @@ -123,8 +122,7 @@ void QtFallbackWebPopup::show() connect(m_combo, SIGNAL(activated(int)), SLOT(activeChanged(int)), Qt::QueuedConnection); - populate(); - m_combo->setCurrentIndex(currentIndex()); + populate(data); QRect rect = geometry(); if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) { @@ -212,7 +210,7 @@ void QtFallbackWebPopup::destroyPopup() } } -void QtFallbackWebPopup::populate() +void QtFallbackWebPopup::populate(const QWebSelectData& data) { QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_combo->model()); Q_ASSERT(model); @@ -220,21 +218,28 @@ void QtFallbackWebPopup::populate() #if !defined(Q_WS_S60) m_combo->setFont(font()); #endif - for (int i = 0; i < itemCount(); ++i) { - switch (itemType(i)) { - case Separator: + + int currentIndex = -1; + for (int i = 0; i < data.itemCount(); ++i) { + switch (data.itemType(i)) { + case QWebSelectData::Separator: m_combo->insertSeparator(i); break; - case Group: - m_combo->insertItem(i, itemText(i)); + case QWebSelectData::Group: + m_combo->insertItem(i, data.itemText(i)); model->item(i)->setEnabled(false); break; - case Option: - m_combo->insertItem(i, itemText(i)); - model->item(i)->setEnabled(itemIsEnabled(i)); + case QWebSelectData::Option: + m_combo->insertItem(i, data.itemText(i)); + model->item(i)->setEnabled(data.itemIsEnabled(i)); + if (data.itemIsSelected(i)) + currentIndex = i; break; } } + + if (currentIndex >= 0) + m_combo->setCurrentIndex(currentIndex); } void QtFallbackWebPopup::activeChanged(int index) @@ -242,7 +247,12 @@ void QtFallbackWebPopup::activeChanged(int index) if (index < 0) return; - valueChanged(index); + emit selectItem(index, false, false); +} + +QWebPageClient* QtFallbackWebPopup::pageClient() const +{ + return m_chromeClient->platformPageClient(); } } diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h index e6c371f..7c98fb4 100644 --- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h +++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h @@ -20,7 +20,9 @@ #ifndef QtFallbackWebPopup_h #define QtFallbackWebPopup_h -#include "QtAbstractWebPopup.h" +#include "Platform.h" +#include "qwebkitplatformplugin.h" + #include <QComboBox> #ifndef QT_NO_COMBOBOX @@ -29,21 +31,30 @@ QT_BEGIN_NAMESPACE class QGraphicsProxyWidget; QT_END_NAMESPACE +class QWebPageClient; + namespace WebCore { +class ChromeClientQt; class QtFallbackWebPopupCombo; -class QtFallbackWebPopup : public QObject, public QtAbstractWebPopup { +class QtFallbackWebPopup : public QWebSelectMethod { Q_OBJECT public: - QtFallbackWebPopup(); + QtFallbackWebPopup(const ChromeClientQt*); ~QtFallbackWebPopup(); - virtual void show(); + virtual void show(const QWebSelectData&); virtual void hide(); void destroyPopup(); + void setGeometry(const QRect& rect) { m_geometry = rect; } + QRect geometry() const { return m_geometry; } + + void setFont(const QFont& font) { m_font = font; } + QFont font() const { return m_font; } + private slots: void activeChanged(int); @@ -51,8 +62,13 @@ private: friend class QtFallbackWebPopupCombo; bool m_popupVisible; QtFallbackWebPopupCombo* m_combo; + const ChromeClientQt* m_chromeClient; + QRect m_geometry; + QFont m_font; + + QWebPageClient* pageClient() const; - void populate(); + void populate(const QWebSelectData&); #if ENABLE(SYMBIAN_DIALOG_PROVIDERS) void showS60BrowserDialog(); #endif diff --git a/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp index 29a16cb..90af0c6 100644 --- a/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp +++ b/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp @@ -41,11 +41,11 @@ void Maemo5Popup::populateList() { QListWidgetItem* listItem; for (int i = 0; i < m_data.itemCount(); ++i) { - if (m_data.itemType(i) == QtAbstractWebPopup::Option) { + if (m_data.itemType(i) == QWebSelectData::Option) { listItem = new QListWidgetItem(m_data.itemText(i)); m_list->addItem(listItem); listItem->setSelected(m_data.itemIsSelected(i)); - } else if (m_data.itemType(i) == QtAbstractWebPopup::Group) { + } else if (m_data.itemType(i) == QWebSelectData::Group) { listItem = new QListWidgetItem(m_data.itemText(i)); m_list->addItem(listItem); listItem->setSelected(false); @@ -62,8 +62,7 @@ void Maemo5Popup::onItemSelected(QListWidgetItem* item) } QtMaemoWebPopup::QtMaemoWebPopup() - : QtAbstractWebPopup() - , m_popup(0) + : m_popup(0) { } @@ -73,30 +72,30 @@ QtMaemoWebPopup::~QtMaemoWebPopup() m_popup->deleteLater(); } -Maemo5Popup* QtMaemoWebPopup::createSingleSelectionPopup() +Maemo5Popup* QtMaemoWebPopup::createSingleSelectionPopup(const QWebSelectData& data) { - return new Maemo5SingleSelectionPopup(*this); + return new Maemo5SingleSelectionPopup(data); } -Maemo5Popup* QtMaemoWebPopup::createMultipleSelectionPopup() +Maemo5Popup* QtMaemoWebPopup::createMultipleSelectionPopup(const QWebSelectData& data) { - return new Maemo5MultipleSelectionPopup(*this); + return new Maemo5MultipleSelectionPopup(data); } -Maemo5Popup* QtMaemoWebPopup::createPopup() +Maemo5Popup* QtMaemoWebPopup::createPopup(const QWebSelectData& data) { - Maemo5Popup* result = multiple() ? createMultipleSelectionPopup() : createSingleSelectionPopup(); + Maemo5Popup* result = data.multiple() ? createMultipleSelectionPopup(data) : createSingleSelectionPopup(data); connect(result, SIGNAL(finished(int)), this, SLOT(popupClosed())); connect(result, SIGNAL(itemClicked(int)), this, SLOT(itemClicked(int))); return result; } -void QtMaemoWebPopup::show() +void QtMaemoWebPopup::show(const QWebSelectData& data) { - if (!pageClient() || m_popup) + if (m_popup) return; - m_popup = createPopup(); + m_popup = createPopup(data); m_popup->show(); } @@ -115,15 +114,15 @@ void QtMaemoWebPopup::popupClosed() m_popup->deleteLater(); m_popup = 0; - popupDidHide(); + emit didHide(); } void QtMaemoWebPopup::itemClicked(int idx) { - selectItem(idx, true, false); + emit selectItem(idx, true, false); } -Maemo5SingleSelectionPopup::Maemo5SingleSelectionPopup(QtAbstractWebPopup& data) +Maemo5SingleSelectionPopup::Maemo5SingleSelectionPopup(const QWebSelectData& data) : Maemo5Popup(data) { // we try to get the standard list title the web browser is using @@ -170,7 +169,7 @@ private: QPixmap tickMark; }; -Maemo5MultipleSelectionPopup::Maemo5MultipleSelectionPopup(QtAbstractWebPopup& data) +Maemo5MultipleSelectionPopup::Maemo5MultipleSelectionPopup(const QWebSelectData& data) : Maemo5Popup(data) { // we try to get the standard list title the web browser is using diff --git a/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h b/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h index a163a20..5433b75 100644 --- a/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h +++ b/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h @@ -20,7 +20,7 @@ #ifndef QtMaemoWebPopup_h #define QtMaemoWebPopup_h -#include "QtAbstractWebPopup.h" +#include "qwebkitplatformplugin.h" #include <QDialog> @@ -33,7 +33,7 @@ namespace WebCore { class Maemo5Popup : public QDialog { Q_OBJECT public: - Maemo5Popup(QtAbstractWebPopup& data) : m_data(data) {} + Maemo5Popup(const QWebSelectData& data) : m_data(data) {} signals: void itemClicked(int idx); @@ -44,18 +44,18 @@ protected slots: protected: void populateList(); - QtAbstractWebPopup& m_data; + const QWebSelectData& m_data; QListWidget* m_list; }; -class QtMaemoWebPopup : public QObject, public QtAbstractWebPopup { +class QtMaemoWebPopup : public QWebSelectMethod { Q_OBJECT public: QtMaemoWebPopup(); ~QtMaemoWebPopup(); - virtual void show(); + virtual void show(const QWebSelectData& data); virtual void hide(); private slots: @@ -65,23 +65,23 @@ private slots: private: Maemo5Popup* m_popup; - Maemo5Popup* createPopup(); - Maemo5Popup* createSingleSelectionPopup(); - Maemo5Popup* createMultipleSelectionPopup(); + Maemo5Popup* createPopup(const QWebSelectData& data); + Maemo5Popup* createSingleSelectionPopup(const QWebSelectData& data); + Maemo5Popup* createMultipleSelectionPopup(const QWebSelectData& data); }; class Maemo5SingleSelectionPopup : public Maemo5Popup { Q_OBJECT public: - Maemo5SingleSelectionPopup(QtAbstractWebPopup& data); + Maemo5SingleSelectionPopup(const QWebSelectData& data); }; class Maemo5MultipleSelectionPopup : public Maemo5Popup { Q_OBJECT public: - Maemo5MultipleSelectionPopup(QtAbstractWebPopup& data); + Maemo5MultipleSelectionPopup(const QWebSelectData& data); }; } diff --git a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp index cccb07c..fd86e91 100644 --- a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp +++ b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp @@ -29,70 +29,6 @@ namespace WebCore { -class SelectData : public QWebSelectData { -public: - SelectData(QtAbstractWebPopup* data) : d(data) {} - - virtual ItemType itemType(int) const; - virtual QString itemText(int index) const { return d->itemText(index); } - virtual QString itemToolTip(int index) const { return d->itemToolTip(index); } - virtual bool itemIsEnabled(int index) const { return d->itemIsEnabled(index); } - virtual int itemCount() const { return d->itemCount(); } - virtual bool itemIsSelected(int index) const { return d->itemIsSelected(index); } - virtual bool multiple() const { return d->multiple(); } - -private: - QtAbstractWebPopup* d; -}; - -QWebSelectData::ItemType SelectData::itemType(int index) const -{ - switch (d->itemType(index)) { - case QtAbstractWebPopup::Separator: return Separator; - case QtAbstractWebPopup::Group: return Group; - default: return Option; - } -} - -SelectInputMethodWrapper::SelectInputMethodWrapper(QWebSelectMethod* plugin) - : m_plugin(plugin) - , m_selectData(0) -{ - m_plugin->setParent(this); - connect(m_plugin, SIGNAL(didHide()), this, SLOT(didHide())); - connect(m_plugin, SIGNAL(selectItem(int, bool, bool)), this, SLOT(selectItem(int, bool, bool))); -} - -SelectInputMethodWrapper::~SelectInputMethodWrapper() -{ - delete m_selectData; -} - -void SelectInputMethodWrapper::show() -{ - if (m_selectData) - delete m_selectData; - m_selectData = new SelectData(this); - m_plugin->show(*m_selectData); -} - -void SelectInputMethodWrapper::hide() -{ - m_plugin->hide(); -} - -void SelectInputMethodWrapper::selectItem(int index, bool allowMultiplySelections, bool shift) -{ - QtAbstractWebPopup::selectItem(index, allowMultiplySelections, shift); -} - -void SelectInputMethodWrapper::didHide() -{ - QtAbstractWebPopup::popupDidHide(); -} - -// QtPlatformPlugin - bool QtPlatformPlugin::load(const QString& file) { m_loader.setFileName(file); @@ -152,17 +88,10 @@ QWebKitPlatformPlugin* QtPlatformPlugin::plugin() return m_plugin; } -QtAbstractWebPopup* QtPlatformPlugin::createSelectInputMethod() +QWebSelectMethod* QtPlatformPlugin::createSelectInputMethod() { QWebKitPlatformPlugin* p = plugin(); - if (!p) - return 0; - - QWebSelectMethod* selector = p->createSelectInputMethod(); - if (!selector) - return 0; - - return new SelectInputMethodWrapper(selector); + return p ? p->createSelectInputMethod() : 0; } diff --git a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h index 2de4859..9bdab75 100644 --- a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h +++ b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h @@ -21,8 +21,6 @@ #ifndef QtPlatformPlugin_h #define QtPlatformPlugin_h -#include "QtAbstractWebPopup.h" -#include <QObject> #include <QPluginLoader> class QWebSelectMethod; @@ -32,30 +30,12 @@ class QWebSelectData; namespace WebCore { -class SelectInputMethodWrapper : public QObject, public QtAbstractWebPopup { - Q_OBJECT -public: - SelectInputMethodWrapper(QWebSelectMethod* plugin); - ~SelectInputMethodWrapper(); - - virtual void show(); - virtual void hide(); - -private Q_SLOTS: - void selectItem(int index, bool allowMultiplySelections, bool shift); - void didHide(); - -private: - QWebSelectMethod* m_plugin; - QWebSelectData* m_selectData; -}; - class QtPlatformPlugin { public: QtPlatformPlugin() : m_loaded(false), m_plugin(0) {} ~QtPlatformPlugin(); - QtAbstractWebPopup* createSelectInputMethod(); + QWebSelectMethod* createSelectInputMethod(); QWebNotificationPresenter* createNotificationPresenter(); QWebKitPlatformPlugin* plugin(); diff --git a/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.cpp b/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.cpp new file mode 100644 index 0000000..63437cf --- /dev/null +++ b/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.cpp @@ -0,0 +1,49 @@ +/* + * Copyright C 2006 Zack Rusin <zack@kde.org> + * 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 "config.h" +#include "SearchPopupMenuQt.h" + +namespace WebCore { + +SearchPopupMenuQt::SearchPopupMenuQt(PassRefPtr<PopupMenu> popup) + : m_popup(popup) +{ +} + +PopupMenu* SearchPopupMenuQt::popupMenu() +{ + return m_popup.get(); +} + +void SearchPopupMenuQt::saveRecentSearches(const AtomicString&, const Vector<String>&) +{ +} + +void SearchPopupMenuQt::loadRecentSearches(const AtomicString&, Vector<String>&) +{ +} + +bool SearchPopupMenuQt::enabled() +{ + return true; +} + +} diff --git a/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h b/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h new file mode 100644 index 0000000..11a9641 --- /dev/null +++ b/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h @@ -0,0 +1,43 @@ +/* + * 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 SearchPopupMenuQt_h +#define SearchPopupMenuQt_h + +#include "SearchPopupMenu.h" + +namespace WebCore { + +class SearchPopupMenuQt : public SearchPopupMenu { +public: + SearchPopupMenuQt(PassRefPtr<PopupMenu> popup); + + virtual PopupMenu* popupMenu(); + virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems); + virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems); + virtual bool enabled(); + +private: + RefPtr<PopupMenu> m_popup; +}; + +} + +#endif // SearchPopupMenuQt_h diff --git a/WebKit/qt/docs/qtwebkit-bridge.qdoc b/WebKit/qt/docs/qtwebkit-bridge.qdoc index c2a38fd..0947a0a 100644 --- a/WebKit/qt/docs/qtwebkit-bridge.qdoc +++ b/WebKit/qt/docs/qtwebkit-bridge.qdoc @@ -7,69 +7,66 @@ \section2 The technology The QtWebKit bridge is a mechanism that extends WebKit's JavaScript environment to access native - objects that are represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection, - a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, - for example \l{QObject} properties map directly to JavaScript properties. - - For example, both JavaScript and QObjects have properties: a construct that represent a getter/setter - pair under one name. + objects represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection, + a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment. + For example \l{QObject} properties map directly to JavaScript properties. \section2 Use Cases - There are two main use cases for the QtWebKit bridge. Web content in a native application, and Thin Clients. + There are two main use cases for the QtWebKit bridge: web content in native applications and thin clients. - \section3 Web Content in a Native Application + \section3 Web Content in Native Applications This is a common use case in classic Qt application, and a design pattern used by several modern - applications. For example, an application that contains a media-player, playlist manager, and music store. + applications like an application that contains a media-player, playlist manager, and music store. The playlist manager is usually best authored as a classic desktop application, - with the native-looking robust \l{QWidget}s helping with producing that application. - The media-player control, which usually looks custom, can be written using the \l{Graphics View framework} - or with in a declarative way with \l{QtDeclarative}. The music store, which shows dynamic content - from the internet and gets modified rapidly, is best authored in HTML and maintained on the server. + with the native-looking robust \l{QWidget}s as the application's backbone. + The media-player control usually has a custom look and feel and is best written using the \l{Graphics View framework} + or \l{QtDeclarative}. The music store, which shows dynamic content + from the Internet and gets modified rapidly, is best authored in HTML and maintained on the server. - With the QtWebKit bridge, that music store component can interact with native parts of the application, - for example, if a file needs to be saved to a specific location. + With the QtWebKit bridge, the music store component can interact with native parts of the application, + for example, when a file needs to be saved to a specific location. - \section3 Thin Client + \section3 Thin Clients - Another use case is using Qt as a native backend to a full web application, - referred to here as a thin client. In this use-case, the entire UI is driven by - HTML, JavaScript and CSS, and native Qt-based components are used to allow that application - access to native features not usually exposed to the web, or to enable helper components that - are best written with C++. + The use case uses Qt as a native backend of a full web application, + a so-called thin client. In this use case, the entire UI is driven by + HTML, JavaScript and CSS. Additionally, it uses Qt-based components to + access native features usually not exposed to the web, or to enable helper + components that are best written in C++. An example for such a client is a UI for a video-on-demand service on a TV. The entire content and - UI can be kept on the server, served dynamically through HTTP and rendered with WebKit, with additional - native components for accessing hardware-specific features like extracting the list of images - out of the video. + UI can be kept on the server, served dynamically through HTTP and rendered with WebKit. Additional + native components are used to access hardware-specific features like extracting a list of images + out of a video stream. \section2 Difference from Other Bridge Technologies - Of course QtWebKit is not the only bridge technology out there. NPAPI, for example, - is a long-time standard or web-native bridging. Due to Qt's meta-object system, full applications - built partially with web-technologies are much easier to develop. NPAPI, however, is more geared - towards cross-browser plugins, due to it being an accepted standard. + Of course, QtWebKit is not the only bridge technology out there. NPAPI, for example, + is a long-time standard for web-native bridging. Due to Qt's meta-object system, full applications + leveraging web technologies are much easier to develop with the QtWebKit bridge than with NPAPI. NPAPI, however, is better + for cross-browser plugins, due to it being an accepted standard. When developing a plugin for a browser, NPAPI is recommended. When developing a full application - that utilizes HTML-rendering, the QtWebKit bridge is recommended. + utilizing HTML-rendering, the QtWebKit bridge is recommended. \section2 Relationship with QtScript - The QtWebKit bridge is similar to \l{QtScript}, especially to some of the features described in the - \l{Making Applications Scriptable} page. However, as of Qt 4.7, full QtScript API is not supported for web applications. - That is planned as an enhancement for future versions. You might notice that some of the features + The QtWebKit bridge is similar to \l{QtScript}, especially for some of the features described in the + \l{Making Applications Scriptable} page. However, Qt 4.7 does not provide the full QtScript API for web applications. + Full support is planned for future versions. You might notice that some of the features described here are an exact copy of the ones described in the \l{Making Applications Scriptable} page. That is because the QtWebKit bridge is a subset of that functionality, and this page tries to capture the full capabilities available through the QtWebKit bridge specifically. \section1 Accessing QObjects - \section2 Creating the link via QWebFrame + \section2 Making QObjects known to JavaScript via QWebFrame By default, no QObjects are accessible through the web environment, for security reasons. - To enable web content access for a native QObject, the application must explicitly grant it access, - using the following call: + When a web application wants to access a native QObject, it must explicitly grant access + to this QObject, using the following call: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 0 @@ -83,13 +80,11 @@ \list \i \bold{Hybrid C++/script}: C++ application code connects a - signal to a script function. For example, the script function can be - a function that the user has typed in, or one that you have read from a - file. This approach is useful if you have a QObject but don't want - to expose the object itself to the scripting environment; you just - want a script to be able to define how a signal should be reacted - to, and leave it up to the C++ side of your application to establish - the connection. + signal to a script function. This approach is useful if you have + a QObject but don't want to expose the object itself to the scripting + environment. You just want to define how the script responds to a + signal and leave it up to the C++ side of your application to establish + the connection between the C++ signal and the JavaScript slot. \i \bold{Hybrid script/C++}: A script can connect signals and slots to establish connections between pre-defined objects that the @@ -109,27 +104,24 @@ \section3 Signal to Function Connections - \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 6 - - In this form of connection, the argument to \c{connect()} is the - function to connect to the signal. - \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 7 - The argument can be a JavaScript function, as in the above - example, or it can be a QObject slot, as in - the following example: + The call to \c{connect()} establishes a connection between the signal + \c{somethingChanged} and the slot \c{myInterestingScriptFunction}. + Whenever the object \c{myObject} emits the signal \c{somethingChanged}, + the slot \c{myInterestingScriptFunction} gets called automatically. + + The argument of \c{connect()} can be any JavaScript function as in the above + example or a slot of a QObject as in the following example: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 8 - When the argument is a QObject slot, the argument types of the - signal and slot do not necessarily have to be compatible; - If necessary, the QtWebKit bridge will, perform conversion of the signal - arguments to match the argument types of the slot. + When the argument is a slot of a QObject, the argument types of the + signal and the slot do not have to be compatible. If possible, the QtWebKit + bridge converts the signal arguments such that they match the slot argument. - To disconnect from a signal, you invoke the signal's - \c{disconnect()} function, passing the function to disconnect - as argument: + To disconnect a slot from a signal, you call the signal's + \c{disconnect()} function with the slot as its argument: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 9 @@ -140,18 +132,24 @@ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 10 - In this form of the \c{connect()} function, the first argument - is the object that will be bound to the variable, \c this, when - the function specified using the second argument is invoked. + The call to \c{connect() establishes a connection between the signal + \c{somethingChanged} and the slot \c{function}. Whenever the object + \c{myObject} emits the signal \c{somethingChanged}, the slot \c{function} + of the object \c{thisObject} gets called automatically. Let's illustrate + this with an example. - If you have a push button in a form, you typically want to do - something involving the form in response to the button's - \c{clicked} signal; passing the form as the \c this object - makes sense in such a case. + If you have a push button in a form, you typically want the form + to do something in response to the button's \c{clicked} signal. The + call to \c{connect()} makes sure that the function \c{onClicked()} is + called whenever you click on the push button, that is, whenever the + the signal \c{clicked()} is emitted by \c{myButton}. The slot \c{onClicked()} + prints the value of \c{x} as stored in the \c{form}. \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 11 - To disconnect from the signal, pass the same arguments to \c{disconnect()}: + To disconnect a slot from a signal, you pass the same arguments to + \c{disconnect()} as you passed to \c{connect()}. In general, this looks + as follows: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 12 @@ -159,19 +157,19 @@ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 14 - This form of the \c{connect()} function requires that the first argument is - the object that will be bound to the variable \c{this} when a function is - invoked in response to the signal. The second argument specifies the - name of a function that is connected to the signal, and this refers to a - member function of the object passed as the first argument (thisObject - in the above scheme). + This form of the \c{connect()} function requires that the first argument \c{thisObject} is + the object that will be bound to \c{this} when the function \c{functionName} is + invoked in response to the signal \c{somethingChanged}. The second argument \c{functionName} specifies the + name of a function that is connected to the signal. It refers to a + member function of the object \c{thisObject}. Note that the function is resolved when the connection is made, not when the signal is emitted. \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 15 - To disconnect from the signal, pass the same arguments to \c{disconnect()}: + To disconnect from the signal, pass the same arguments to \c{disconnect()} + as you passed to \c{connect}: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 17 @@ -220,17 +218,17 @@ \section3 Invokable Methods - Both slots and signals are invokable from script by default. In addition, it's also - possible to define a method that's invokable from script without it being a signal or a slot. + Both slots and signals are invokable from scripts by default. In addition, it is also + possible to define a method that is invokable from scripts, although the method is neither a signal nor a slot. This is especially useful for functions with return types, as slots normally do not return anything - (it would be meaningless to return values from a slot, as the connected signals don't handle the returned data). + (it would be meaningless to return a value from a slot, as the connected signals cannot handle return values). To make a non-slot method invokable, simply add the Q_INVOKABLE macro before its definition: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 22 \section2 Accessing Properties - The properties of the QObject are available as properties + The properties of a QObject are available as properties of the corresponding JavaScript object. When you manipulate a property in script code, the C++ get/set method for that property will automatically be invoked. For example, if your @@ -244,8 +242,8 @@ \section2 Accessing Child QObjects - Every named child of the QObject (that is, for which - QObject::objectName() is not an empty string) is by default available as + Every named child of a QObject (that is, every child for which + QObject::objectName() does not return the empty string) is by default available as a property of the JavaScript wrapper object. For example, if you have a QDialog with a child widget whose \c{objectName} property is \c{"okButton"}, you can access this object in script code through @@ -253,8 +251,8 @@ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 25 - Since \c{objectName} is itself a Q_PROPERTY, you can manipulate - the name in script code to, for example, rename an object: + Because \c{objectName} is itself a Q_PROPERTY, you can manipulate + the name in script code to rename an object. For example: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 26 @@ -270,16 +268,15 @@ \section3 Numbers All Qt numeric data types are converted to or from a JavaScript number. These include int, short, float, - double, and the porable Qt types (qreal, qint etc). A special case is \l{QChar}; - If a slot expects a QChar, the QtWebKit bridge would use the unicode value in case of a number, - or the first character in a string. + double, and the portable Qt types (qreal, qint etc). A special case is \l{QChar}. + If a slot expects a QChar, the QtWebKit bridge uses the Unicode value in case of a number and the first character in case of a string. - Note that non-standard (typedefed) number types are not automatically converted to - or from a JavaScript number - it's advised to use standard number types for signal, slots + Note that non-standard (typedef'ed) number types are not automatically converted to + or from a JavaScript number - we suggest to use standard number types for signals, slots and properties. When a non-number is passed as an argument to a method or property that expects a number, - the appropriate JavaScript conversion function (parseInt / parseFloat) would be used. + the appropriate JavaScript conversion function (parseInt / parseFloat) is used. \section3 Strings @@ -287,42 +284,41 @@ will automatically convert the value to a string (if it is not already a string), using the built-in JavaScript toString method. - When a QString is passed to JavaScript from a signal or a property, The QtWebKit bridge will - convert it into a JavaScript string. + When a QString is passed to JavaScript from a signal or a property, the QtWebKit bridge + converts it into a JavaScript string. \section3 Date & Time Both \l{QDate}, \l{QTime} and \l{QDateTime} are automatically translated to or from the JavaScript - Date object. If a number were passed as an argument to a method that expects one of the date/time - types, the QtWebKit bridge would treat it as a timestamp. If a sting is passed, QtWebKit would - try different Qt date parsing functions to find the right one. + Date object. If a number is passed as an argument to a method that expects one of the date/time + types, the QtWebKit bridge treats it as a timestamp. If a sting is passed, QtWebKit + tries the different Qt date parsing functions to perform the right translation. \section3 Regular Expressions - The QtWebKit bridge would automatically convert JavaScript RegEx object to a \l{QRegExp}. - If a string is passed to a method expecting a \l{QRegExp}, the string would be converted - to that \l{QRegExp}. + The QtWebKit bridge automatically converts a JavaScript RegEx object to a \l{QRegExp}. + If a string is passed to a method expecting a \l{QRegExp}, the string is converted + to a \l{QRegExp}. \section3 Lists The QtWebKit bridge treats several types of lists in a special way: \l{QVariantList}, \l{QStringList}, \l{QObjectList} and \l{QList}<int>. When a slot or property expects one of those list types, - the QtWebKit bridge would try to convert a JavaScript array into that type, converting each of + the QtWebKit bridge tries to convert a JavaScript array into that type, converting each of the array's elements to the single-element type of the list. - The most useful type of list is perhaps \l{QVariantList}, which can be converted to from any + The most useful type of list is \l{QVariantList}, which can be converted to and from any JavaScript array. \section3 Compound (JSON) objects JavaScript compound objects, also known as JSON objects, are variables that hold a list of key-value pairs, where all the keys are strings and the values can have any type. - This translates very well to \l{QVariantMap}, which is nothing more than a \l{QMap} of \l{QString} + This translates very well to \l{QVariantMap}, which is nothing more than a \l{QMap} from \l{QString} to \l{QVariant}. The seamless conversion between JSON objects and \l{QVariantMap} allows for a very convenient - way of passing arbitrary structured data between C++ and the JavaScript environment. The native \l{QObject} has - to make sure that compound values are converted to \l{QVariantMap}s and \l{QVariantList}s, and JavaScript is + way of passing arbitrary structured data between C++ and the JavaScript environment. If the native \l{QObject} makes sure that compound values are converted to \l{QVariantMap}s and \l{QVariantList}s, JavaScript is guaranteed to receive them in a meaningful way. Note that types that are not supported by JSON, such as JavaScript functions and getters/setters, @@ -330,22 +326,22 @@ \section3 QVariants - When a slot or property accepts a \l{QVariant}, the QtWebKit bridge would create a \l{QVariant} that best - matches the argument passed by JavaScript. A string, for example, would become a \l{QVariant} holding a \l{QString}, - a normal JSON object would become a \l{QVariantMap}, and a JavaScript array would become a \l{QVariantList}. + When a slot or property accepts a \l{QVariant}, the QtWebKit bridge creates a \l{QVariant} that best + matches the argument passed by JavaScript. A string, for example, becomes a \l{QVariant} holding a \l{QString}, + a normal JSON object becomes a \l{QVariantMap}, and a JavaScript array becomes a \l{QVariantList}. Using \l{QVariant}s generously in C++ in that way makes C++ programming feel a bit more like JavaScript programming, - as it adds another level of indirection. Passing \l{QVariant}s around like this q is very flexible, as the program can figure out - the type of argument in runtime just like JavaScript would do, but it also takes away from the type-safety and robust - nature of C++. It's recommended to use \l{QVariant}s only for convenience high-level functions, and to keep most of your - \l{QObject}s somewhat type-safe. + as it adds another level of indirection. Passing \l{QVariant}s around like this is very flexible. The program can figure out + the type of argument at runtime just like JavaScript would do. But doing so also takes away the type safety and robustness of C++. + We recommended to use \l{QVariant}s only for high-level functions, and to keep most of your + \l{QObject}s type-safe. \section3 QObjects - A pointer to a \l{QObject} or a \l{QWidget} can be passed as payload in signals, slots and properties. That object - can then be used like an object that's exposed directly; i.e. its slots can be invoked, its signals connected to etc. + Pointers to a \l{QObject} or a \l{QWidget} can be used in signals, slots and properties. This object + can then be used like an object that is exposed directly. Its slots can be invoked, its signals connected to, etc. However, this functionality is fairly limited - the type used has to be \l{QObject}* or \l{QWidget}*. If the type - specified is a pointer to a non-\l{QWidget} subclass of \l{QObject}, the QtWebKit bridge would not recognize it to be + specified is a pointer to a non-\l{QWidget} subclass of \l{QObject}, the QtWebKit bridge does not recognize it as a \l{QObject}. In general its advised to use care when passing \l{QObject}s as arguments, as those objects don't become owned by @@ -358,14 +354,14 @@ The QtWebKit bridge handles \l{QPixmap}s and \l{QImage}s in a special way. Since QtWebKit stores \l{QPixmap}s to represent HTML images, \l{QPixmap}s coming from the native environment can be used directly inside WebKit. - A \l{QImage} or a \l{QPixmap} coming from the Qt environment would convert to an intermediate JavaScript object, - that can be represented like this: + A \l{QImage} or a \l{QPixmap} coming from Qt is converted to an intermediate JavaScript object, + which can be represented like this: \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 1 - The JavaScript environment can then use the pixmap it gets from Qt and display it inside the HTML environment, - by assigning it to an existing <img /> element using assignToHTMLImageElement. It can also use the toDataURL() function, - which allows using the pixmap as the src attribute of an image or as a background-image url. Note that the toDataURL() + The JavaScript environment can then use the pixmap from Qt and display it inside the HTML environment, + by assigning it to an existing \c{<img>} element with \c{assignToHTMLImageElement()}. It can also use the \c{toDataURL()} function, + which allows using the pixmap as the \c{src} attribute of an image or as a \c{background-image} URL. Note that the \c{toDataURL()} function is costly and should be used with caution. Example code: @@ -394,30 +390,30 @@ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 5 This is specifically useful to create custom renderers or extensions to the web environment. Instead of forcing Qt - to select the element, the web environment already selects the element and then send the selected element directly to Qt. + to select the element, the web environment selects the element and then sends the selected element directly to Qt. Note that \l{QWebElement}s are not thread safe - an object handling them has to live in the UI thread. - \section1 Architecture issues + \section1 Architecture Issues \section2 Limiting the Scope of the Hybrid Layer When using QtWebKit's hybrid features, it is a common pitfall to make the API exposed to JavaScript very rich and - use all its features. This, however, leads to complexity and can create bugs that are hard to trace. + use all its features. This, however, leads to complexity and can create bugs that are hard to find. Instead, it is advisable to keep the hybrid layer small and manageable: create a gate only when there's an actual need for it, i.e. there's a new native enabler that requires a direct interface to the application layer. Sometimes new functionality is better handled internally in the native layer or in the web layer; simplicity is your friend. This usually becomes more apparent when the hybrid layer can create or destroy objects, or uses - signals slots or properties with a \l{QObject}* argument. It is advised to be very careful and to treat + signals, slots or properties with a \l{QObject}* argument. It is advised to be very careful and to treat an exposed \l{QObject} as a system - with careful attention to memory management and object ownership. \section2 Internet Security - When exposing native object to an open web environment, it is importwhichant to understand the security - implications. Think whether the exposed object enables the web environment access to things that - shouldn't be open, and whether the web content loaded by that web page comes from a trusted. In general, when + When exposing native objects to an open web environment, it is important to understand the security + implications. Think whether the exposed object enables the web environment access things that + shouldn't be open, and whether the web content loaded by that web page comes from a trusted source. In general, when exposing native QObjects that give the web environment access to private information or to functionality that's potentially harmful to the client, such exposure should be balanced by limiting the web page's access to trusted URLs only with HTTPS, and by utilizing other measures as part of a security strategy. diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp index 6a517c2..75aa0a9 100644 --- a/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp +++ b/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp @@ -95,21 +95,21 @@ class MyObject : QObject { myQObject.somethingChanged.disconnect(myOtherQObject.doSomething); //! [9] //! [10] - connect(thisObject, function) + myQObject.somethingChanged.connect(thisObject, function) //! [10] //! [11] - var obj = { x: 123 }; - var fun = function() { print(this.x); }; - myQObject.somethingChanged.connect(obj, fun); + var form = { x: 123 }; + var onClicked = function() { print(this.x); }; + myButton.clicked.connect(form, onClicked); //! [11] //! [12] - myQObject.somethingChanged.disconnect(obj, fun); + myQObject.somethingChanged.disconnect(thisObject, function); //! [12] //! [13] connect(function); //! [13] //! [14] - connect(thisObject, functionName) + myQObject.somethingChanged.connect(thisObject, "functionName") //! [14] //! [15] var obj = { x: 123, fun: function() { print(this.x); } }; @@ -119,7 +119,7 @@ class MyObject : QObject { connect(function); //! [16] //! [17] - myQObject.somethingChanged.disconnect(obj, "fun"); + myQObject.somethingChanged.disconnect(thisObject, "functionName"); //! [17] //! [18] try { @@ -145,8 +145,8 @@ class MyObject : QObject { Q_OBJECT public: - Q_INVOKABLE void thisMethodIsInvokableInQtScript(); - void thisMethodIsNotInvokableInQtScript(); + Q_INVOKABLE void thisMethodIsInvokableInJavaScript(); + void thisMethodIsNotInvokableInJavaScript(); ... }; diff --git a/WebKit/qt/examples/platformplugin/WebPlugin.h b/WebKit/qt/examples/platformplugin/WebPlugin.h index 9a99d0b..4af19f9 100644 --- a/WebKit/qt/examples/platformplugin/WebPlugin.h +++ b/WebKit/qt/examples/platformplugin/WebPlugin.h @@ -92,6 +92,9 @@ public: virtual QWebNotificationPresenter* createNotificationPresenter() const { return new WebNotificationPresenter(); } + virtual QWebHapticFeedbackPlayer* createHapticFeedbackPlayer() const { + return 0; + } }; #endif // WEBPLUGIN_H diff --git a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h index 32d22d4..3c56c98 100644 --- a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h +++ b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h @@ -81,6 +81,20 @@ Q_SIGNALS: void notificationClosed(); }; +class QWebHapticFeedbackPlayer +{ +public: + enum HapticStrength { + None, Weak, Medium, Strong + }; + + enum HapticEvent { + Press, Release + }; + + virtual void playHapticFeedback(const HapticEvent, const QString& hapticType, const HapticStrength) = 0; +}; + class QWebKitPlatformPlugin { public: @@ -88,15 +102,17 @@ public: enum Extension { MultipleSelections, - Notifications + Notifications, + Haptics }; virtual bool supportsExtension(Extension extension) const = 0; virtual QWebSelectMethod* createSelectInputMethod() const = 0; virtual QWebNotificationPresenter* createNotificationPresenter() const = 0; + virtual QWebHapticFeedbackPlayer* createHapticFeedbackPlayer() const = 0; }; -Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.2"); +Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.3"); #endif // QWEBKITPLATFORMPLUGIN_H diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index b208447..83b8600 100644 --- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -33,6 +33,7 @@ #include <QRegExp> #include <QNetworkRequest> #include <QNetworkReply> +#include <QTextCodec> #ifndef QT_NO_OPENSSL #include <qsslerror.h> #endif @@ -625,6 +626,8 @@ private slots: void qObjectWrapperWithSameIdentity(); void introspectQtMethods_data(); void introspectQtMethods(); + void setContent_data(); + void setContent(); private: QString evalJS(const QString&s) { @@ -3101,5 +3104,34 @@ void tst_QWebFrame::introspectQtMethods() QVERIFY(evalJSV("var props=[]; for (var p in myObject.deleteLater) {props.push(p);}; props.sort()").toStringList().isEmpty()); } +void tst_QWebFrame::setContent_data() +{ + QTest::addColumn<QString>("mimeType"); + QTest::addColumn<QByteArray>("testContents"); + QTest::addColumn<QString>("expected"); + + QString str = QString::fromUtf8("ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει"); + QTest::newRow("UTF-8 plain text") << "text/plain; charset=utf-8" << str.toUtf8() << str; + + QTextCodec *utf16 = QTextCodec::codecForName("UTF-16"); + if (utf16) + QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << utf16->fromUnicode(str) << str; + + str = QString::fromUtf8("Une chaîne de caractères à sa façon."); + QTest::newRow("latin-1 plain text") << "text/plain; charset=iso-8859-1" << str.toLatin1() << str; + + +} + +void tst_QWebFrame::setContent() +{ + QFETCH(QString, mimeType); + QFETCH(QByteArray, testContents); + QFETCH(QString, expected); + m_view->setContent(testContents, mimeType); + QWebFrame* mainFrame = m_view->page()->mainFrame(); + QCOMPARE(expected , mainFrame->toPlainText()); +} + QTEST_MAIN(tst_QWebFrame) #include "tst_qwebframe.moc" diff --git a/WebKit/qt/tests/qwebview/resources/input_types.html b/WebKit/qt/tests/qwebview/resources/input_types.html index 18ab314..2e893af 100644 --- a/WebKit/qt/tests/qwebview/resources/input_types.html +++ b/WebKit/qt/tests/qwebview/resources/input_types.html @@ -4,5 +4,6 @@ <input type='tel' style='position: absolute; left: 10px; top: 100px; height: 50px; width: 100px;'/><br> <input type='number' style='position: absolute; left: 10px; top: 150px; height: 50px; width: 100px;'/><br> <input type='email' style='position: absolute; left: 10px; top: 200px; height: 50px; width: 100px;'/><br> -<input type='url' style='position: absolute; left: 10px; top: 250px; height: 50px; width: 100px;'/><br>" -</body></html>
\ No newline at end of file +<input type='url' style='position: absolute; left: 10px; top: 250px; height: 50px; width: 100px;'/><br> +<textarea style='position: absolute; left: 10px; top: 310px; height: 50px; width: 100px;' rows="2" cols="20">blah blah blah blah</textarea><br> +</body></html> diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 5dc5e41..57f726d 100644 --- a/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -264,30 +264,37 @@ void tst_QWebView::focusInputTypes() #else QVERIFY(webView->inputMethodHints() == Qt::ImhNone); #endif + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field webView->fireMouseClick(QPoint(20, 60)); QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'tel' field webView->fireMouseClick(QPoint(20, 110)); QVERIFY(webView->inputMethodHints() == Qt::ImhDialableCharactersOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'number' field webView->fireMouseClick(QPoint(20, 160)); QVERIFY(webView->inputMethodHints() == Qt::ImhDigitsOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'email' field webView->fireMouseClick(QPoint(20, 210)); QVERIFY(webView->inputMethodHints() == Qt::ImhEmailCharactersOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'url' field webView->fireMouseClick(QPoint(20, 260)); QVERIFY(webView->inputMethodHints() == Qt::ImhUrlCharactersOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field webView->fireMouseClick(QPoint(20, 60)); QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'text' type webView->fireMouseClick(QPoint(20, 10)); @@ -297,6 +304,17 @@ void tst_QWebView::focusInputTypes() #else QVERIFY(webView->inputMethodHints() == Qt::ImhNone); #endif + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + + // 'password' field + webView->fireMouseClick(QPoint(20, 60)); + QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + + // 'text area' field + webView->fireMouseClick(QPoint(20, 320)); + QVERIFY(webView->inputMethodHints() == Qt::ImhNone); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); delete webView; |