diff options
Diffstat (limited to 'WebKit/qt')
-rw-r--r-- | WebKit/qt/Api/DerivedSources.pro | 6 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.cpp | 29 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.cpp | 60 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.h | 2 | ||||
-rw-r--r-- | WebKit/qt/ChangeLog | 201 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp | 49 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h | 21 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/EditorClientQt.cpp | 219 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp | 7 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp | 121 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h | 34 | ||||
-rw-r--r-- | WebKit/qt/docs/docs.pri | 2 | ||||
-rw-r--r-- | WebKit/qt/examples/platformplugin/README | 11 | ||||
-rw-r--r-- | WebKit/qt/examples/platformplugin/WebPlugin.cpp | 216 | ||||
-rw-r--r-- | WebKit/qt/examples/platformplugin/WebPlugin.h | 95 | ||||
-rw-r--r-- | WebKit/qt/examples/platformplugin/platformplugin.pro | 13 | ||||
-rw-r--r-- | WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h | 77 | ||||
-rw-r--r-- | WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 28 |
18 files changed, 1050 insertions, 141 deletions
diff --git a/WebKit/qt/Api/DerivedSources.pro b/WebKit/qt/Api/DerivedSources.pro index 389fb5f..22d4c8d 100644 --- a/WebKit/qt/Api/DerivedSources.pro +++ b/WebKit/qt/Api/DerivedSources.pro @@ -28,7 +28,7 @@ qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}define QT_QTWEBKIT_MOD qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}include $${ESCAPE}<QtNetwork/QtNetwork$${ESCAPE}>$${QUOTE} >> $${qtheader_module.target} && WEBKIT_CLASS_HEADERS = $${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}PWD/QtWebKit -regex = ".*\sclass\sQWEBKIT_EXPORT\s(\w+)\s(.*)" +regex = ".*\\sclass\\sQWEBKIT_EXPORT\\s(\\w+)\\s(.*)" for(HEADER, WEBKIT_API_HEADERS) { # 1. Append to QtWebKit header that includes all other header files @@ -70,7 +70,7 @@ for(HEADER, WEBKIT_API_HEADERS) { res = $$find(src, $$regex) isEmpty(res):break() - exp = $$replace(src, $$regex, "EXPORTED_CLASS = \1") + exp = $$replace(src, $$regex, "EXPORTED_CLASS = \\1") eval($$exp) CLASS_TARGET = "qtheader_$${EXPORTED_CLASS}" @@ -87,7 +87,7 @@ for(HEADER, WEBKIT_API_HEADERS) { # Qt's QRegExp does not support inline non-greedy matching, # so we'll have to work around it by updating the haystack - src = $$replace(src, $$regex, "\2") + src = $$replace(src, $$regex, "\\2") src_words = $$join(src, $${LITERAL_WHITESPACE}) } } diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 4b12545..7a28f83 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -55,6 +55,7 @@ #include "ScriptSourceCode.h" #include "ScriptValue.h" #include "Scrollbar.h" +#include "Settings.h" #include "SelectionController.h" #include "SubstituteData.h" #include "SVGSMILElement.h" @@ -1079,7 +1080,11 @@ void QWebFrame::render(QPainter* painter) */ void QWebFrame::setTextSizeMultiplier(qreal factor) { - d->frame->setZoomFactor(factor, ZoomTextOnly); + FrameView* view = d->frame->view(); + if (!view) + return; + + view->setZoomFactor(factor, ZoomTextOnly); } /*! @@ -1087,7 +1092,11 @@ void QWebFrame::setTextSizeMultiplier(qreal factor) */ qreal QWebFrame::textSizeMultiplier() const { - return d->frame->zoomFactor(); + FrameView* view = d->frame->view(); + if (!view) + return 1; + + return view->zoomFactor(); } /*! @@ -1098,12 +1107,24 @@ qreal QWebFrame::textSizeMultiplier() const void QWebFrame::setZoomFactor(qreal factor) { - d->frame->setZoomFactor(factor, d->frame->zoomMode()); + Page* page = d->frame->page(); + if (!page) + return; + + FrameView* view = d->frame->view(); + if (!view) + return; + + view->setZoomFactor(factor, page->settings()->zoomMode()); } qreal QWebFrame::zoomFactor() const { - return d->frame->zoomFactor(); + FrameView* view = d->frame->view(); + if (!view) + return 1; + + return view->zoomFactor(); } /*! diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 1ae8e35..0e9d92f 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -299,7 +299,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) PageGroup::setShouldTrackVisitedLinks(true); #if ENABLE(NOTIFICATIONS) - notificationPresenterClient = new NotificationPresenterClientQt(); + notificationPresenterClient = new NotificationPresenterClientQt(q); #endif } @@ -1220,7 +1220,42 @@ void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* ev } else if (event->propertyName() == "_q_HTMLTokenizerTimeDelay") { double timeDelay = q->property("_q_HTMLTokenizerTimeDelay").toDouble(); q->handle()->page->setCustomHTMLTokenizerTimeDelay(timeDelay); + } +#if ENABLE(TILED_BACKING_STORE) + else if (event->propertyName() == "_q_TiledBackingStoreTileSize") { + WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame()); + if (!frame->tiledBackingStore()) + return; + QSize tileSize = q->property("_q_TiledBackingStoreTileSize").toSize(); + frame->tiledBackingStore()->setTileSize(tileSize); + } else if (event->propertyName() == "_q_TiledBackingStoreTileCreationDelay") { + WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame()); + if (!frame->tiledBackingStore()) + return; + int tileCreationDelay = q->property("_q_TiledBackingStoreTileCreationDelay").toInt(); + frame->tiledBackingStore()->setTileCreationDelay(static_cast<double>(tileCreationDelay) / 1000.); + } else if (event->propertyName() == "_q_TiledBackingStoreKeepAreaMultiplier") { + WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame()); + if (!frame->tiledBackingStore()) + return; + FloatSize keepMultiplier; + FloatSize coverMultiplier; + frame->tiledBackingStore()->getKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier); + QSizeF qSize = q->property("_q_TiledBackingStoreKeepAreaMultiplier").toSizeF(); + keepMultiplier = FloatSize(qSize.width(), qSize.height()); + frame->tiledBackingStore()->setKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier); + } else if (event->propertyName() == "_q_TiledBackingStoreCoverAreaMultiplier") { + WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame()); + if (!frame->tiledBackingStore()) + return; + FloatSize keepMultiplier; + FloatSize coverMultiplier; + frame->tiledBackingStore()->getKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier); + QSizeF qSize = q->property("_q_TiledBackingStoreCoverAreaMultiplier").toSizeF(); + coverMultiplier = FloatSize(qSize.width(), qSize.height()); + frame->tiledBackingStore()->setKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier); } +#endif } void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event) @@ -1543,6 +1578,7 @@ InspectorController* QWebPagePrivate::inspectorController() \value Back Navigate back in the history of navigated links. \value Forward Navigate forward in the history of navigated links. \value Stop Stop loading the current page. + \value StopScheduledPageRefresh Stop all pending page refresh/redirect requests. \value Reload Reload the current page. \value ReloadAndBypassCache Reload the current page, but do not use any local cache. (Added in Qt 4.6) \value Cut Cut the content currently selected into the clipboard. @@ -1948,6 +1984,15 @@ static void openNewWindow(const QUrl& url, WebCore::Frame* frame) } } +static void collectChildFrames(QWebFrame* frame, QList<QWebFrame*>& list) +{ + list << frame->childFrames(); + QListIterator<QWebFrame*> it(frame->childFrames()); + while (it.hasNext()) { + collectChildFrames(it.next(), list); + } +} + /*! This function can be called to trigger the specified \a action. It is also called by QtWebKit if the user triggers the action, for example @@ -2044,6 +2089,16 @@ void QWebPage::triggerAction(WebAction action, bool) #endif break; } + case StopScheduledPageRefresh: { + QWebFrame* topFrame = mainFrame(); + topFrame->d->frame->redirectScheduler()->cancel(); + QList<QWebFrame*> childFrames; + collectChildFrames(topFrame, childFrames); + QListIterator<QWebFrame*> it(childFrames); + while (it.hasNext()) + it.next()->d->frame->redirectScheduler()->cancel(); + break; + } default: command = QWebPagePrivate::editorCommandForWebActions(action); break; @@ -2638,8 +2693,7 @@ void QWebPage::setContentEditable(bool editable) frame->applyEditingStyleToBodyElement(); // FIXME: mac port calls this if there is no selectedDOMRange //frame->setSelectionFromNone(); - } else - frame->removeEditingStyleFromBodyElement(); + } } d->updateEditorActions(); diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index c085fd7..a4b555a 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -170,6 +170,8 @@ public: AlignLeft, AlignRight, + StopScheduledPageRefresh, + WebActionCount }; diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index bc1f45d..14548d9 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,204 @@ +2010-05-31 Lyon Chen <liachen@rim.com> + + Reviewed by Kent Tamura. + + Enum value FORWARD, BACKWARD, RIGHT, LEFT are causing macro conflicts. + https://bugs.webkit.org/show_bug.cgi?id=35530 + + Change enum EAlteration from { MOVE, EXTEND } to { AlterationMove, AlterationExtend } and enum EDirection { FORWARD, BACKWARD, RIGHT, LEFT} to { DirectionForward, DirectionBackward, DirectionRight, DirectionLeft } to avoid macro conflict, and also better coding style conformance. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::handleKeyboardEvent): + +2010-05-31 Oswald Buddenhagen <oswald.buddenhagen@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Escape backslashes in the .pro files + + qmake in Qt 4.7 warns about unescaped backspaces and deprecates them. + + * Api/DerivedSources.pro: + * docs/docs.pri: + +2010-05-30 Lyon Chen <liachen@rim.com> + + Reviewed by Kent Tamura. + + This is a coding style cleanup before fixing to bug 35530. + + Enum value FORWARD, BACKWARD, RIGHT, LEFT are causing macro conflicts. + https://bugs.webkit.org/show_bug.cgi?id=35530 + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::registerCommandForUndo): + (WebCore::EditorClientQt::handleKeyboardEvent): + +2010-05-29 Dawit Alemayehu <adawit@kde.org> + + Reviewed by Kenneth Rohde Christiansen. + + Added a WebAction to stop all pending page refresh/redirect + requests set through the <meta http-equiv="refresh"...> tag. + + https://bugs.webkit.org/show_bug.cgi?id=29899 + + * Api/qwebpage.cpp: + (QWebPage::triggerAction): + * Api/qwebpage.h: + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::testStopScheduledPageRefresh): + +2010-05-28 Antti Koivisto <koivisto@iki.fi> + + Reviewed by Kenneth Rohde Christiansen. + + Add a missing #if ENABLE(), some null checking. + + * Api/qwebpage.cpp: + (QWebPagePrivate::dynamicPropertyChangeEvent): + +2010-05-28 Antti Koivisto <koivisto@iki.fi> + + Reviewed by Kenneth Rohde Christiansen. + + https://bugs.webkit.org/show_bug.cgi?id=39874 + [Qt] Make tiled backing store more configurable + + Make tile size, tile creation delay and tiling area dynamically configurable. + + * Api/qwebpage.cpp: + (QWebPagePrivate::dynamicPropertyChangeEvent): + +2010-05-28 Yael Aharon <yael.aharon@nokia.com> + + Unreviewed build fix after r60348. + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::setNotificationsReceiver): + +2010-05-28 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Laszlo Gombos. + + [Qt] Pass all web notification layout tests + https://bugs.webkit.org/show_bug.cgi?id=39146 + + Add support for multiple simultaneous notifications. + Add a private callback mechanism to the client for security checks. + Notifications are disabled if the client does not set the callbacks. + Support replaceId and cancel. + Send close and display events when needed. + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::setNotificationsReceiver): + (DumpRenderTreeSupportQt::allowNotificationForOrigin): + (DumpRenderTreeSupportQt::setCheckPermissionFunction): + (DumpRenderTreeSupportQt::setRequestPermissionFunction): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld): + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (NotificationIconWrapper::NotificationIconWrapper): + (NotificationIconWrapper::~NotificationIconWrapper): + (NotificationPresenterClientQt::NotificationPresenterClientQt): + (NotificationPresenterClientQt::show): + (NotificationPresenterClientQt::cancel): + (NotificationPresenterClientQt::notificationObjectDestroyed): + (NotificationPresenterClientQt::requestPermission): + (NotificationPresenterClientQt::checkPermission): + (NotificationPresenterClientQt::allowNotificationForOrigin): + (NotificationPresenterClientQt::clearNotificationsList): + (NotificationPresenterClientQt::sendEvent): + * WebCoreSupport/NotificationPresenterClientQt.h: + (WebCore::NotificationPresenterClientQt::~NotificationPresenterClientQt): + (WebCore::NotificationPresenterClientQt::setReceiver): + +2010-05-27 Luiz Agostini <luiz.agostini@openbossa.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Platform plugin example + https://bugs.webkit.org/show_bug.cgi?id=39489 + + Adding a Qt platform plugin example to repository. + + * examples/platformplugin/README: Added. + * examples/platformplugin/WebPlugin.cpp: Added. + (Popup::populateList): + (Popup::onItemSelected): + (WebPopup::WebPopup): + (WebPopup::~WebPopup): + (WebPopup::createSingleSelectionPopup): + (WebPopup::createMultipleSelectionPopup): + (WebPopup::createPopup): + (WebPopup::show): + (WebPopup::hide): + (WebPopup::popupClosed): + (WebPopup::itemClicked): + (SingleSelectionPopup::SingleSelectionPopup): + (MultipleItemListDelegate::MultipleItemListDelegate): + (MultipleItemListDelegate::paint): + (MultipleSelectionPopup::MultipleSelectionPopup): + (WebPlugin::supportsExtension): + * examples/platformplugin/WebPlugin.h: Added. + (Popup::Popup): + (WebPlugin::createSelectInputMethod): + * examples/platformplugin/platformplugin.pro: Added. + * examples/platformplugin/qwebkitplatformplugin.h: Copied from WebKit/qt/Api/qwebkitplatformplugin.h. + (QWebSelectData::~QWebSelectData): + (QWebSelectData::): + (QWebSelectMethod::~QWebSelectMethod): + (QWebKitPlatformPlugin::~QWebKitPlatformPlugin): + (QWebKitPlatformPlugin::): + +2010-05-25 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Ojan Vafai. + + [Qt] Expose the editing behavior setting in DRT to test all editing code paths + https://bugs.webkit.org/show_bug.cgi?id=39680 + + Add support to Qt's DRT to setting the editing behavior. Patch is a follow up of + bug 38603, which just stubbed out the Qt bits of it. + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: Implementation of editing behavior control. + (DumpRenderTreeSupportQt::setEditingBehavior): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + +2010-05-24 Robert Hogan <robert@webkit.org> + + Reviewed by Laszlo Gombos. + + [Qt] DRT Support for removeOriginAccessWhitelistEntry + + Unskips http/tests/xmlhttprequest/origin-whitelisting-removal.html + + [Qt] DRT Support for removeOriginAccessWhitelistEntry + https://bugs.webkit.org/show_bug.cgi?id=39565 + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::removeWhiteListAccessFromOrigin): + * WebCoreSupport/DumpRenderTreeSupportQt.h: + +2010-05-24 Darin Adler <darin@apple.com> + + Reviewed by Eric Seidel. + + Move view-related functions from Frame to FrameView + https://bugs.webkit.org/show_bug.cgi?id=39366 + + * Api/qwebframe.cpp: + (QWebFrame::setTextSizeMultiplier): Call functions on FrameView. + (QWebFrame::textSizeMultiplier): Ditto. + (QWebFrame::setZoomFactor): Ditto. + (QWebFrame::zoomFactor): Ditto. + * Api/qwebpage.cpp: + (QWebPage::setContentEditable): Removed call to empty function, + removeEditingStyleFromBodyElement. + 2010-05-23 Noam Rosenthal <noam.rosenthal@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index 9d335b8..0b2e9a5 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -60,6 +60,9 @@ using namespace WebCore; +CheckPermissionFunctionType* checkPermissionFunction = 0; +RequestPermissionFunctionType* requestPermissionFunction = 0; + DumpRenderTreeSupportQt::DumpRenderTreeSupportQt() { } @@ -332,6 +335,11 @@ void DumpRenderTreeSupportQt::whiteListAccessFromOrigin(const QString& sourceOri SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); } +void DumpRenderTreeSupportQt::removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) +{ + SecurityOrigin::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); +} + void DumpRenderTreeSupportQt::resetOriginAccessWhiteLists() { SecurityOrigin::resetOriginAccessWhitelists(); @@ -466,6 +474,22 @@ bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrame* && inputElement->autoComplete()); } +void DumpRenderTreeSupportQt::setEditingBehavior(QWebPage* page, const QString& editingBehavior) +{ + WebCore::EditingBehavior coreEditingBehavior; + + if (editingBehavior == "win") + coreEditingBehavior = EditingWindowsBehavior; + else if (editingBehavior == "mac") + coreEditingBehavior = EditingMacBehavior; + + Page* corePage = QWebPagePrivate::core(page); + if (!corePage) + return; + + corePage->settings()->setEditingBehavior(coreEditingBehavior); +} + void DumpRenderTreeSupportQt::dumpFrameLoader(bool b) { FrameLoaderClientQt::dumpFrameLoaderCallbacks = b; @@ -512,6 +536,31 @@ void DumpRenderTreeSupportQt::dumpNotification(bool b) NotificationPresenterClientQt::dumpNotification = b; #endif } + +void DumpRenderTreeSupportQt::setNotificationsReceiver(QWebPage* page, QObject* receiver) +{ +#if ENABLE(NOTIFICATIONS) + page->d->notificationPresenterClient->setReceiver(receiver); +#endif +} + +void DumpRenderTreeSupportQt::allowNotificationForOrigin(QWebPage* page, const QString& origin) +{ +#if ENABLE(NOTIFICATIONS) + page->d->notificationPresenterClient->allowNotificationForOrigin(origin); +#endif +} + +void DumpRenderTreeSupportQt::setCheckPermissionFunction(CheckPermissionFunctionType* f) +{ + checkPermissionFunction = f; +} + +void DumpRenderTreeSupportQt::setRequestPermissionFunction(RequestPermissionFunctionType* f) +{ + requestPermissionFunction = f; +} + // Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame) diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index 6045463..0d348cf 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -30,6 +30,18 @@ class QWebElement; class QWebFrame; class QWebPage; +enum NotificationPermission { + NotificationAllowed, + NotificationNotAllowed, + NotificationDenied +}; + +typedef void (CheckPermissionFunctionType) (QObject* receiver, const QUrl&, NotificationPermission&); +typedef void (RequestPermissionFunctionType) (QObject* receiver, QWebPage* page, const QString&); + +extern CheckPermissionFunctionType* checkPermissionFunction; +extern RequestPermissionFunctionType* requestPermissionFunction; + class QWEBKIT_EXPORT DumpRenderTreeSupportQt { public: @@ -78,8 +90,10 @@ public: static int pageNumberForElementById(QWebFrame* frame, const QString& id, float width, float height); static bool hasDocumentElement(QWebFrame* frame); static bool elementDoesAutoCompleteForElementWithId(QWebFrame* frame, const QString& elementId); + static void setEditingBehavior(QWebPage* page, const QString& editingBehavior); static void whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); + static void removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); static void resetOriginAccessWhiteLists(); static int workerThreadCount(); @@ -98,7 +112,12 @@ public: static void dumpSetAcceptsEditing(bool b); static void dumpNotification(bool b); - + // These functions should eventually turn into public API + // and the "receiver" concept would go away + static void setNotificationsReceiver(QWebPage* page, QObject* receiver); + static void allowNotificationForOrigin(QWebPage* page, const QString& origin); + static void setCheckPermissionFunction(CheckPermissionFunctionType*); + static void setRequestPermissionFunction(RequestPermissionFunctionType*); }; #endif diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 83aa2a9..0f54e21 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -31,9 +31,6 @@ #include "config.h" #include "EditorClientQt.h" -#include "qwebpage.h" -#include "qwebpage_p.h" - #include "CSSStyleDeclaration.h" #include "Document.h" #include "EditCommandQt.h" @@ -46,15 +43,16 @@ #include "KeyboardEvent.h" #include "NotImplemented.h" #include "Page.h" -#include "Page.h" #include "PlatformKeyboardEvent.h" #include "QWebPageClient.h" #include "Range.h" #include "WindowsKeyboardCodes.h" +#include "qwebpage.h" +#include "qwebpage_p.h" +#include <QUndoStack> #include <stdio.h> -#include <QUndoStack> #define methodDebug() qDebug("EditorClientQt: %s", __FUNCTION__); static QString dumpPath(WebCore::Node *node) @@ -247,9 +245,8 @@ void EditorClientQt::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand { #ifndef QT_NO_UNDOSTACK Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); - if (m_inUndoRedo || (frame && !frame->editor()->lastEditCommand() /* HACK!! Don't recreate undos */)) { + if (m_inUndoRedo || (frame && !frame->editor()->lastEditCommand() /* HACK!! Don't recreate undos */)) return; - } m_page->undoStack()->push(new EditCommandQt(cmd)); #endif // QT_NO_UNDOSTACK } @@ -378,118 +375,120 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) } else #endif // QT_NO_SHORTCUT switch (kevent->windowsVirtualKeyCode()) { - case VK_BACK: - frame->editor()->deleteWithDirection(SelectionController::BACKWARD, - CharacterGranularity, false, true); - break; - case VK_DELETE: - frame->editor()->deleteWithDirection(SelectionController::FORWARD, - CharacterGranularity, false, true); - break; - case VK_LEFT: - if (kevent->shiftKey()) - frame->editor()->command("MoveLeftAndModifySelection").execute(); - else - frame->editor()->command("MoveLeft").execute(); - break; - case VK_RIGHT: - if (kevent->shiftKey()) - frame->editor()->command("MoveRightAndModifySelection").execute(); - else - frame->editor()->command("MoveRight").execute(); - break; - case VK_UP: - if (kevent->shiftKey()) - frame->editor()->command("MoveUpAndModifySelection").execute(); - else - frame->editor()->command("MoveUp").execute(); - break; - case VK_DOWN: - if (kevent->shiftKey()) - frame->editor()->command("MoveDownAndModifySelection").execute(); - else - frame->editor()->command("MoveDown").execute(); - break; - case VK_PRIOR: // PageUp - if (kevent->shiftKey()) - frame->editor()->command("MovePageUpAndModifySelection").execute(); - else - frame->editor()->command("MovePageUp").execute(); - break; - case VK_NEXT: // PageDown - if (kevent->shiftKey()) - frame->editor()->command("MovePageDownAndModifySelection").execute(); - else - frame->editor()->command("MovePageDown").execute(); - break; - case VK_TAB: - return; - default: - if (kevent->type() != PlatformKeyboardEvent::KeyDown && !kevent->ctrlKey() + case VK_BACK: + frame->editor()->deleteWithDirection(SelectionController::DirectionBackward, + CharacterGranularity, false, true); + break; + case VK_DELETE: + frame->editor()->deleteWithDirection(SelectionController::DirectionForward, + CharacterGranularity, false, true); + break; + case VK_LEFT: + if (kevent->shiftKey()) + frame->editor()->command("MoveLeftAndModifySelection").execute(); + else + frame->editor()->command("MoveLeft").execute(); + break; + case VK_RIGHT: + if (kevent->shiftKey()) + frame->editor()->command("MoveRightAndModifySelection").execute(); + else + frame->editor()->command("MoveRight").execute(); + break; + case VK_UP: + if (kevent->shiftKey()) + frame->editor()->command("MoveUpAndModifySelection").execute(); + else + frame->editor()->command("MoveUp").execute(); + break; + case VK_DOWN: + if (kevent->shiftKey()) + frame->editor()->command("MoveDownAndModifySelection").execute(); + else + frame->editor()->command("MoveDown").execute(); + break; + case VK_PRIOR: // PageUp + if (kevent->shiftKey()) + frame->editor()->command("MovePageUpAndModifySelection").execute(); + else + frame->editor()->command("MovePageUp").execute(); + break; + case VK_NEXT: // PageDown + if (kevent->shiftKey()) + frame->editor()->command("MovePageDownAndModifySelection").execute(); + else + frame->editor()->command("MovePageDown").execute(); + break; + case VK_TAB: + return; + default: + if (kevent->type() != PlatformKeyboardEvent::KeyDown && !kevent->ctrlKey() #ifndef Q_WS_MAC - // We need to exclude checking for Alt because it is just a different Shift - && !kevent->altKey() + // We need to exclude checking for Alt because it is just a different Shift + && !kevent->altKey() #endif - && !kevent->text().isEmpty()) { - frame->editor()->insertText(kevent->text(), event); - } else if (kevent->ctrlKey()) { - switch (kevent->windowsVirtualKeyCode()) { - case VK_A: - frame->editor()->command("SelectAll").execute(); - break; - case VK_B: - frame->editor()->command("ToggleBold").execute(); - break; - case VK_I: - frame->editor()->command("ToggleItalic").execute(); - break; - default: - // catch combination AltGr+key or Ctrl+Alt+key - if (kevent->type() != PlatformKeyboardEvent::KeyDown && kevent->altKey() && !kevent->text().isEmpty()) { - frame->editor()->insertText(kevent->text(), event); - break; - } - return; + && !kevent->text().isEmpty()) { + frame->editor()->insertText(kevent->text(), event); + } else if (kevent->ctrlKey()) { + switch (kevent->windowsVirtualKeyCode()) { + case VK_A: + frame->editor()->command("SelectAll").execute(); + break; + case VK_B: + frame->editor()->command("ToggleBold").execute(); + break; + case VK_I: + frame->editor()->command("ToggleItalic").execute(); + break; + default: + // catch combination AltGr+key or Ctrl+Alt+key + if (kevent->type() != PlatformKeyboardEvent::KeyDown && kevent->altKey() && !kevent->text().isEmpty()) { + frame->editor()->insertText(kevent->text(), event); + break; } - } else return; + return; + } + } else + return; } } else { #ifndef QT_NO_SHORTCUT - if (kevent->qtEvent() == QKeySequence::Copy) { + if (kevent->qtEvent() == QKeySequence::Copy) m_page->triggerAction(QWebPage::Copy); - } else + else #endif // QT_NO_SHORTCUT switch (kevent->windowsVirtualKeyCode()) { - case VK_UP: - frame->editor()->command("MoveUp").execute(); - break; - case VK_DOWN: - frame->editor()->command("MoveDown").execute(); - break; - case VK_PRIOR: // PageUp - frame->editor()->command("MovePageUp").execute(); - break; - case VK_NEXT: // PageDown - frame->editor()->command("MovePageDown").execute(); - break; - case VK_HOME: - if (kevent->ctrlKey()) - frame->editor()->command("MoveToBeginningOfDocument").execute(); - break; - case VK_END: - if (kevent->ctrlKey()) - frame->editor()->command("MoveToEndOfDocument").execute(); - break; - default: - if (kevent->ctrlKey()) { - switch (kevent->windowsVirtualKeyCode()) { - case VK_A: - frame->editor()->command("SelectAll").execute(); - break; - default: - return; - } - } else return; + case VK_UP: + frame->editor()->command("MoveUp").execute(); + break; + case VK_DOWN: + frame->editor()->command("MoveDown").execute(); + break; + case VK_PRIOR: // PageUp + frame->editor()->command("MovePageUp").execute(); + break; + case VK_NEXT: // PageDown + frame->editor()->command("MovePageDown").execute(); + break; + case VK_HOME: + if (kevent->ctrlKey()) + frame->editor()->command("MoveToBeginningOfDocument").execute(); + break; + case VK_END: + if (kevent->ctrlKey()) + frame->editor()->command("MoveToEndOfDocument").execute(); + break; + default: + if (kevent->ctrlKey()) { + switch (kevent->windowsVirtualKeyCode()) { + case VK_A: + frame->editor()->command("SelectAll").execute(); + break; + default: + return; + } + } else + return; } } event->setDefaultHandled(); diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 00359c0..3cf19a6 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -51,6 +51,7 @@ #include "HTMLFormElement.h" #include "HTMLPlugInElement.h" #include "HTTPParsers.h" +#include "NotificationPresenterClientQt.h" #include "NotImplemented.h" #include "QNetworkReplyHandler.h" #include "ResourceHandleInternal.h" @@ -638,8 +639,12 @@ void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* w if (world != mainThreadNormalWorld()) return; - if (m_webFrame) + if (m_webFrame) { emit m_webFrame->javaScriptWindowObjectCleared(); +#if ENABLE(NOTIFICATIONS) + m_webFrame->page()->d->notificationPresenterClient->clearNotificationsList(); +#endif + } } void FrameLoaderClientQt::documentElementAvailable() diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index d6546ae..f76868d 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -32,13 +32,15 @@ #include "config.h" #include "NotificationPresenterClientQt.h" +#include "DumpRenderTreeSupportQt.h" #include "Document.h" +#include "EventNames.h" #include "KURL.h" -#include "NotImplemented.h" #include "SecurityOrigin.h" +#include "qwebframe.h" #include "qwebkitglobal.h" - +#include "qwebpage.h" #include <QtGui> @@ -48,25 +50,66 @@ using namespace WebCore; bool NotificationPresenterClientQt::dumpNotification = false; -NotificationPresenterClientQt::NotificationPresenterClientQt() +NotificationIconWrapper::NotificationIconWrapper() +{ +#ifndef QT_NO_SYSTEMTRAYICON + m_notificationIcon = 0; +#endif +} + +NotificationIconWrapper::~NotificationIconWrapper() +{ +#ifndef QT_NO_SYSTEMTRAYICON + delete m_notificationIcon; +#endif +} + +NotificationPresenterClientQt::NotificationPresenterClientQt(QWebPage* page) : m_page(page) { } bool NotificationPresenterClientQt::show(Notification* notification) { + QHash <Notification*, NotificationIconWrapper*>::Iterator end = m_notifications.end(); + QHash <Notification*, NotificationIconWrapper*>::Iterator iter = m_notifications.begin(); + + if (!notification->replaceId().isEmpty()) { + while (iter != end) { + Notification* existingNotification = iter.key(); + if (existingNotification->replaceId() == notification->replaceId() && existingNotification->url().protocol() == notification->url().protocol() && existingNotification->url().host() == notification->url().host()) + break; + iter++; + } + } else + iter = end; + if (dumpNotification) { + if (iter != end) { + Notification* oldNotification = iter.key(); + printf("REPLACING NOTIFICATION %s\n", oldNotification->isHTML() ? QString(oldNotification->url().string()).toUtf8().constData() : QString(oldNotification->contents().title()).toUtf8().constData()); + } if (notification->isHTML()) printf("DESKTOP NOTIFICATION: contents at %s\n", QString(notification->url().string()).toUtf8().constData()); else { - printf("DESKTOP NOTIFICATION: icon %s, title %s, text %s\n", + printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n", + notification->dir() == "rtl" ? "(RTL)" : "", QString(notification->contents().icon().string()).toUtf8().constData(), QString(notification->contents().title()).toUtf8().constData(), QString(notification->contents().body()).toUtf8().constData()); } } + if (iter != end) { + sendEvent(iter.key(), eventNames().closeEvent); + delete m_notifications.take(iter.key()); + } + NotificationIconWrapper* wrapper = new NotificationIconWrapper(); + m_notifications.insert(notification, wrapper); + sendEvent(notification, "display"); + #ifndef QT_NO_SYSTEMTRAYICON - m_tray.show(); - m_tray.showMessage(notification->contents().title(), notification->contents().body(), QSystemTrayIcon::Information); + wrapper->m_notificationIcon = new QSystemTrayIcon; + wrapper->m_notificationIcon->show(); + wrapper->m_notificationIcon->showMessage(notification->contents().title(), notification->contents().body()); #endif return true; } @@ -80,12 +123,17 @@ void NotificationPresenterClientQt::cancel(Notification* notification) printf("DESKTOP NOTIFICATION CLOSED: %s\n", QString(notification->contents().title()).toUtf8().constData()); } - notImplemented(); + QHash <Notification*, NotificationIconWrapper*>::Iterator iter = m_notifications.find(notification); + if (iter != m_notifications.end()) + sendEvent(iter.key(), eventNames().closeEvent); } void NotificationPresenterClientQt::notificationObjectDestroyed(Notification* notification) { - notImplemented(); + // Called from ~Notification(), Remove the entry from the notifications list and delete the icon. + QHash <Notification*, NotificationIconWrapper*>::Iterator iter = m_notifications.find(notification); + if (iter != m_notifications.end()) + delete m_notifications.take(notification); } void NotificationPresenterClientQt::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback) @@ -93,13 +141,62 @@ void NotificationPresenterClientQt::requestPermission(SecurityOrigin* origin, Pa if (dumpNotification) printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(origin->toString()).toUtf8().constData()); - notImplemented(); + QString originString = origin->toString(); + QHash<QString, QList<RefPtr<VoidCallback> > >::iterator iter = m_pendingPermissionRequests.find(originString); + if (iter != m_pendingPermissionRequests.end()) + iter.value().append(callback); + else { + QList<RefPtr<VoidCallback> > callbacks; + RefPtr<VoidCallback> cb = callback; + callbacks.append(cb); + m_pendingPermissionRequests.insert(originString, callbacks); + if (requestPermissionFunction) + requestPermissionFunction(m_receiver, m_page, originString); + } +} + +NotificationPresenter::Permission NotificationPresenterClientQt::checkPermission(const KURL& url) +{ + NotificationPermission permission = NotificationNotAllowed; + QString origin = url.string(); + if (checkPermissionFunction) + checkPermissionFunction(m_receiver, origin, permission); + switch (permission) { + case NotificationAllowed: + return NotificationPresenter::PermissionAllowed; + case NotificationNotAllowed: + return NotificationPresenter::PermissionNotAllowed; + case NotificationDenied: + return NotificationPresenter::PermissionDenied; + } + ASSERT_NOT_REACHED(); + return NotificationPresenter::PermissionNotAllowed; +} + +void NotificationPresenterClientQt::allowNotificationForOrigin(const QString& origin) +{ + QHash<QString, QList<RefPtr<VoidCallback> > >::iterator iter = m_pendingPermissionRequests.find(origin); + if (iter != m_pendingPermissionRequests.end()) { + QList<RefPtr<VoidCallback> >& callbacks = iter.value(); + for (int i = 0; i < callbacks.size(); i++) + callbacks.at(i)->handleEvent(); + m_pendingPermissionRequests.remove(origin); + } +} + +void NotificationPresenterClientQt::clearNotificationsList() +{ + m_pendingPermissionRequests.clear(); + while (!m_notifications.isEmpty()) { + QHash <Notification*, NotificationIconWrapper*>::Iterator iter = m_notifications.begin(); + delete m_notifications.take(iter.key()); + } } -NotificationPresenter::Permission NotificationPresenterClientQt::checkPermission(const KURL&) +void NotificationPresenterClientQt::sendEvent(Notification* notification, const AtomicString& eventName) { - // FIXME Implement permission policy - return NotificationPresenter::PermissionAllowed; + RefPtr<Event> event = Event::create(eventName, false, true); + notification->dispatchEvent(event.release()); } #endif // ENABLE(NOTIFICATIONS) diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index 5967867..c949513 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -29,20 +29,35 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef NotificationPresenterClientQt_h +#define NotificationPresenterClientQt_h + #include "Notification.h" #include "NotificationPresenter.h" +#include <QMultiHash> #include <QSystemTrayIcon> + #if ENABLE(NOTIFICATIONS) +class QWebPage; namespace WebCore { class Document; class KURL; +struct NotificationIconWrapper { + NotificationIconWrapper(); + ~NotificationIconWrapper(); +#ifndef QT_NO_SYSTEMTRAYICON + QSystemTrayIcon* m_notificationIcon; +#endif +}; + class NotificationPresenterClientQt : public NotificationPresenter { public: - NotificationPresenterClientQt(); + NotificationPresenterClientQt(QWebPage*); + ~NotificationPresenterClientQt() {} /* WebCore::NotificationPresenter interface */ virtual bool show(Notification*); @@ -51,13 +66,22 @@ public: virtual void requestPermission(SecurityOrigin*, PassRefPtr<VoidCallback>); virtual NotificationPresenter::Permission checkPermission(const KURL&); + void allowNotificationForOrigin(const QString& origin); + void clearNotificationsList(); + static bool dumpNotification; -private: -#ifndef QT_NO_SYSTEMTRAYICON - QSystemTrayIcon m_tray; -#endif + void setReceiver(QObject* receiver) { m_receiver = receiver; } + +private: + void sendEvent(Notification*, const AtomicString& eventName); + QWebPage* m_page; + QMultiHash<QString, QList<RefPtr<VoidCallback> > > m_pendingPermissionRequests; + QHash <Notification*, NotificationIconWrapper*> m_notifications; + QObject* m_receiver; }; } #endif +#endif + diff --git a/WebKit/qt/docs/docs.pri b/WebKit/qt/docs/docs.pri index 804817b..a56ddb4 100644 --- a/WebKit/qt/docs/docs.pri +++ b/WebKit/qt/docs/docs.pri @@ -3,7 +3,7 @@ include(../../../WebKit.pri) unix { QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/bin/qdoc3 } else { - QDOC = $$(QTDIR)\bin\qdoc3.exe + QDOC = $$(QTDIR)\\bin\\qdoc3.exe } unix { diff --git a/WebKit/qt/examples/platformplugin/README b/WebKit/qt/examples/platformplugin/README new file mode 100644 index 0000000..47ef797 --- /dev/null +++ b/WebKit/qt/examples/platformplugin/README @@ -0,0 +1,11 @@ +Platform plugin example. + +This project will create a shared library named platformplugin in directory $$[QT_INSTALL_PLUGINS]/webkit +that will provide combo boxes popups to QtWebKit. + +QtWebKit will look for the plugins automatically so there is no need to make any other configuration to +put the plugin into use. To stop using the plugin just remove the directory $$[QT_INSTALL_PLUGINS]/webkit. + +This plugin can provide popups for <select multiple> elements but to use this feature QtWebKit must be +compiled with NO_LISTBOX_RENDERING enabled. + diff --git a/WebKit/qt/examples/platformplugin/WebPlugin.cpp b/WebKit/qt/examples/platformplugin/WebPlugin.cpp new file mode 100644 index 0000000..79e583d --- /dev/null +++ b/WebKit/qt/examples/platformplugin/WebPlugin.cpp @@ -0,0 +1,216 @@ +/* + * 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 "WebPlugin.h" + +#include <QHBoxLayout> +#include <QListWidget> +#include <QListWidgetItem> +#include <QPainter> +#include <QtPlugin> +#include <QPushButton> +#include <QStyledItemDelegate> +#include <QVBoxLayout> + +static const int gMaemoListItemSize = 70; +static const int gMaemoListPadding = 38; +static const int gMaemoMaxVisibleItems = 5; + +void Popup::populateList() +{ + QListWidgetItem* listItem; + for (int i = 0; i < m_data.itemCount(); ++i) { + 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) == QWebSelectData::Group) { + listItem = new QListWidgetItem(m_data.itemText(i)); + m_list->addItem(listItem); + listItem->setSelected(false); + listItem->setFlags(Qt::NoItemFlags); + } + } + connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemSelected(QListWidgetItem*))); +} + +void Popup::onItemSelected(QListWidgetItem* item) +{ + if (item->flags() != Qt::NoItemFlags) + emit itemClicked(m_list->row(item)); +} + +WebPopup::WebPopup() + : m_popup(0) +{ +} + +WebPopup::~WebPopup() +{ + if (m_popup) + m_popup->deleteLater(); +} + +Popup* WebPopup::createSingleSelectionPopup(const QWebSelectData& data) +{ + return new SingleSelectionPopup(data); +} + +Popup* WebPopup::createMultipleSelectionPopup(const QWebSelectData& data) +{ + return new MultipleSelectionPopup(data); +} + +Popup* WebPopup::createPopup(const QWebSelectData& data) +{ + Popup* 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 WebPopup::show(const QWebSelectData& data) +{ + if (m_popup) + return; + + m_popup = createPopup(data); + m_popup->show(); +} + +void WebPopup::hide() +{ + if (!m_popup) + return; + + m_popup->accept(); +} + +void WebPopup::popupClosed() +{ + if (!m_popup) + return; + + m_popup->deleteLater(); + m_popup = 0; + emit didHide(); +} + +void WebPopup::itemClicked(int idx) +{ + emit selectItem(idx, true, false); +} + +SingleSelectionPopup::SingleSelectionPopup(const QWebSelectData& data) + : Popup(data) +{ + const char* title = "select"; + if (qstrcmp(title, "weba_ti_texlist_single")) + setWindowTitle(QString::fromUtf8(title)); + else + setWindowTitle("Select item"); + + QHBoxLayout* hLayout = new QHBoxLayout(this); + hLayout->setContentsMargins(0, 0, 0, 0); + + m_list = new QListWidget(this); + populateList(); + + hLayout->addSpacing(gMaemoListPadding); + hLayout->addWidget(m_list); + hLayout->addSpacing(gMaemoListPadding); + + connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(accept())); + + const int visibleItemCount = (m_list->count() > gMaemoMaxVisibleItems) ? gMaemoMaxVisibleItems : m_list->count(); + resize(size().width(), visibleItemCount * gMaemoListItemSize); +} + + +class MultipleItemListDelegate : public QStyledItemDelegate { +public: + MultipleItemListDelegate(QObject* parent = 0) + : QStyledItemDelegate(parent) + { + tickMark = QIcon::fromTheme("widgets_tickmark_list").pixmap(48, 48); + } + + void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const + { + QStyledItemDelegate::paint(painter, option, index); + + if (option.state & QStyle::State_Selected) + painter->drawPixmap(option.rect.width() - tickMark.rect().width(), option.rect.y() + (option.rect.height() / 2 - tickMark.rect().height() / 2), tickMark); + } + +private: + QPixmap tickMark; +}; + +MultipleSelectionPopup::MultipleSelectionPopup(const QWebSelectData& data) + : Popup(data) +{ + const char* title = "select"; + if (qstrcmp(title, "weba_ti_textlist_multi")) + setWindowTitle(QString::fromUtf8(title)); + else + setWindowTitle("Select items"); + + QHBoxLayout* hLayout = new QHBoxLayout(this); + hLayout->setContentsMargins(0, 0, 0, 0); + + m_list = new QListWidget(this); + m_list->setSelectionMode(QAbstractItemView::MultiSelection); + populateList(); + + MultipleItemListDelegate* delegate = new MultipleItemListDelegate(this); + m_list->setItemDelegate(delegate); + + hLayout->addSpacing(gMaemoListPadding); + hLayout->addWidget(m_list); + + QVBoxLayout* vLayout = new QVBoxLayout(); + + const int visibleItemCount = (m_list->count() > gMaemoMaxVisibleItems) ? gMaemoMaxVisibleItems : m_list->count(); + vLayout->addSpacing((visibleItemCount - 1) * gMaemoListItemSize); + + QPushButton* done = new QPushButton(this); + title = "done"; + if (qstrcmp(title, "wdgt_bd_done")) + done->setText(QString::fromUtf8(title)); + else + done->setText("Done"); + + done->setMinimumWidth(178); + vLayout->addWidget(done); + + hLayout->addSpacing(8); + hLayout->addLayout(vLayout); + hLayout->addSpacing(18); + + connect(done, SIGNAL(clicked()), this, SLOT(accept())); + resize(size().width(), visibleItemCount * gMaemoListItemSize); +} + +bool WebPlugin::supportsExtension(Extension extension) const +{ + return extension == MultipleSelections; +} + +Q_EXPORT_PLUGIN2(qwebselectim, WebPlugin) diff --git a/WebKit/qt/examples/platformplugin/WebPlugin.h b/WebKit/qt/examples/platformplugin/WebPlugin.h new file mode 100644 index 0000000..a46a07b --- /dev/null +++ b/WebKit/qt/examples/platformplugin/WebPlugin.h @@ -0,0 +1,95 @@ +/* + * 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 WEBPLUGIN_H +#define WEBPLUGIN_H + +#include "qwebkitplatformplugin.h" + +#include <QDialog> + +class QListWidgetItem; +class QListWidget; + +class Popup : public QDialog { + Q_OBJECT +public: + Popup(const QWebSelectData& data) : m_data(data) { setModal(true); } + +signals: + void itemClicked(int idx); + +protected slots: + void onItemSelected(QListWidgetItem* item); + +protected: + void populateList(); + + const QWebSelectData& m_data; + QListWidget* m_list; +}; + + +class SingleSelectionPopup : public Popup { + Q_OBJECT +public: + SingleSelectionPopup(const QWebSelectData& data); +}; + + +class MultipleSelectionPopup : public Popup { + Q_OBJECT +public: + MultipleSelectionPopup(const QWebSelectData& data); +}; + + +class WebPopup : public QWebSelectMethod { + Q_OBJECT +public: + WebPopup(); + ~WebPopup(); + + virtual void show(const QWebSelectData& data); + virtual void hide(); + +private slots: + void popupClosed(); + void itemClicked(int idx); + +private: + Popup* m_popup; + + Popup* createPopup(const QWebSelectData& data); + Popup* createSingleSelectionPopup(const QWebSelectData& data); + Popup* createMultipleSelectionPopup(const QWebSelectData& data); +}; + +class WebPlugin : public QObject, public QWebKitPlatformPlugin +{ + Q_OBJECT + Q_INTERFACES(QWebKitPlatformPlugin) +public: + virtual QWebSelectMethod* createSelectInputMethod() const { return new WebPopup(); } + virtual bool supportsExtension(Extension extension) const; +}; + + + +#endif // WEBPLUGIN_H diff --git a/WebKit/qt/examples/platformplugin/platformplugin.pro b/WebKit/qt/examples/platformplugin/platformplugin.pro new file mode 100644 index 0000000..c5c665b --- /dev/null +++ b/WebKit/qt/examples/platformplugin/platformplugin.pro @@ -0,0 +1,13 @@ +QT += core gui +TARGET = $$qtLibraryTarget(platformplugin) +TEMPLATE = lib +CONFIG += plugin + +DESTDIR = $$[QT_INSTALL_PLUGINS]/webkit + +SOURCES += \ + WebPlugin.cpp + +HEADERS += \ + WebPlugin.h \ + qwebkitplatformplugin.h diff --git a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h new file mode 100644 index 0000000..7d024ae --- /dev/null +++ b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h @@ -0,0 +1,77 @@ +/* + * 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 QWEBKITPLATFORMPLUGIN_H +#define QWEBKITPLATFORMPLUGIN_H + +/* + * Warning: The contents of this file is not part of the public QtWebKit API + * and may be changed from version to version or even be completely removed. +*/ + +#include <QObject> + +class QWebSelectData +{ +public: + inline ~QWebSelectData() {} + + enum ItemType { Option, Group, Separator }; + + virtual ItemType itemType(int) const = 0; + virtual QString itemText(int index) const = 0; + virtual QString itemToolTip(int index) const = 0; + virtual bool itemIsEnabled(int index) const = 0; + virtual bool itemIsSelected(int index) const = 0; + virtual int itemCount() const = 0; + virtual bool multiple() const = 0; +}; + +class QWebSelectMethod : public QObject +{ + Q_OBJECT +public: + inline ~QWebSelectMethod() {} + + virtual void show(const QWebSelectData&) = 0; + virtual void hide() = 0; + +Q_SIGNALS: + void selectItem(int index, bool allowMultiplySelections, bool shift); + void didHide(); +}; + +class QWebKitPlatformPlugin +{ +public: + inline ~QWebKitPlatformPlugin() {} + + enum Extension { + MultipleSelections + }; + + virtual QWebSelectMethod* createSelectInputMethod() const = 0; + virtual bool supportsExtension(Extension extension) const = 0; + +}; + +Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.0"); + +#endif // QWEBKITPLATFORMPLUGIN_H diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index ceb8aff..630ccce 100644 --- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -122,7 +122,8 @@ private slots: void originatingObjectInNetworkRequests(); void testJSPrompt(); void showModalDialog(); - + void testStopScheduledPageRefresh(); + private: QWebView* m_view; QWebPage* m_page; @@ -2090,5 +2091,30 @@ void tst_QWebPage::showModalDialog() QCOMPARE(res, QString("This is a test")); } +void tst_QWebPage::testStopScheduledPageRefresh() +{ + // Without QWebPage::StopScheduledPageRefresh + QWebPage page1; + page1.setNetworkAccessManager(new TestNetworkManager(&page1)); + page1.mainFrame()->setHtml("<html><head>" + "<meta http-equiv=\"refresh\"content=\"0;URL=http://qt.nokia.com/favicon.ico\">" + "</head><body><h1>Page redirects immediately...</h1>" + "</body></html>"); + QVERIFY(::waitForSignal(&page1, SIGNAL(loadFinished(bool)))); + QTest::qWait(500); + QCOMPARE(page1.mainFrame()->url().toString(), QString("http://qt.nokia.com/favicon.ico")); + + // With QWebPage::StopScheduledPageRefresh + QWebPage page2; + page2.setNetworkAccessManager(new TestNetworkManager(&page2)); + page2.mainFrame()->setHtml("<html><head>" + "<meta http-equiv=\"refresh\"content=\"1;URL=http://qt.nokia.com/favicon.ico\">" + "</head><body><h1>Page redirect test with 1 sec timeout...</h1>" + "</body></html>"); + page2.triggerAction(QWebPage::StopScheduledPageRefresh); + QTest::qWait(1500); + QCOMPARE(page2.mainFrame()->url().toString(), QString("about:blank")); +} + QTEST_MAIN(tst_QWebPage) #include "tst_qwebpage.moc" |