diff options
Diffstat (limited to 'WebKit/qt')
-rw-r--r-- | WebKit/qt/Api/qwebelement.cpp | 2 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.cpp | 2 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.cpp | 37 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.h | 6 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebplugindatabase.cpp | 4 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.cpp | 9 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebview.cpp | 6 | ||||
-rw-r--r-- | WebKit/qt/ChangeLog | 229 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/ChromeClientQt.cpp | 16 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/ChromeClientQt.h | 2 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp | 2 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp | 98 | ||||
-rw-r--r-- | WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h | 60 | ||||
-rw-r--r-- | WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 12 | ||||
-rw-r--r-- | WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 15 | ||||
-rw-r--r-- | WebKit/qt/tests/qwebview/tst_qwebview.cpp | 110 |
16 files changed, 506 insertions, 104 deletions
diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp index 83ee451..f7b1188 100644 --- a/WebKit/qt/Api/qwebelement.cpp +++ b/WebKit/qt/Api/qwebelement.cpp @@ -1446,7 +1446,7 @@ void QWebElement::render(QPainter* painter) FrameView* view = frame->view(); - view->layoutIfNeededRecursive(); + view->updateLayoutAndStyleIfNeededRecursive(); IntRect rect = e->getRect(); diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 1b0c2df..81eabfc 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -286,7 +286,7 @@ void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame: QPainter* painter = context->platformContext(); WebCore::FrameView* view = frame->view(); - view->layoutIfNeededRecursive(); + view->updateLayoutAndStyleIfNeededRecursive(); for (int i = 0; i < vector.size(); ++i) { const QRect& clipRect = vector.at(i); diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 5eee21c..ec415bb 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -81,6 +81,7 @@ #include "Cache.h" #include "runtime/InitializeThreading.h" #include "PageGroup.h" +#include "GeolocationPermissionClientQt.h" #include "NotificationPresenterClientQt.h" #include "PageClientQt.h" #include "WorkerThread.h" @@ -2082,30 +2083,6 @@ bool QWebPage::shouldInterruptJavaScript() #endif } -/*! - \fn bool QWebPage::allowGeolocationRequest() - \since 4.7 - - This function is called whenever a JavaScript program running inside \a frame tries to access user location through navigator.geolocation. - - If the user wants to allow access to location then it should return true; otherwise false. - - The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons. - - \warning Because of binary compatibility constraints, this function is not virtual. If you want to - provide your own implementation in a QWebPage subclass, reimplement the allowGeolocationRequest() - slot in your subclass instead. QtWebKit will dynamically detect the slot and call it. -*/ -bool QWebPage::allowGeolocationRequest(QWebFrame *frame) -{ -#ifdef QT_NO_MESSAGEBOX - return false; -#else - QWidget* parent = (d->client) ? d->client->ownerWidget() : 0; - return QMessageBox::Yes == QMessageBox::information(parent, tr("Location Request by- %1").arg(frame->url().host()), tr("The page wants to access your location information. Do you want to allow the request?"), QMessageBox::Yes, QMessageBox::No); -#endif -} - void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, PermissionPolicy policy) { switch (domain) { @@ -2115,6 +2092,12 @@ void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, Perm NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame); #endif break; + case GeolocationPermissionDomain: +#if ENABLE(GEOLOCATION) + GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame, policy); +#endif + break; + default: break; } @@ -2131,7 +2114,11 @@ void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, Perm If \a type is WebModalDialog, the application must call setWindowModality(Qt::ApplicationModal) on the new window. - \sa acceptNavigationRequest() + \note In the cases when the window creation is being triggered by JavaScript, apart from + reimplementing this method application must also set the JavaScriptCanOpenWindows attribute + of QWebSettings to true in order for it to get called. + + \sa acceptNavigationRequest(), QWebView::createWindow() */ QWebPage *QWebPage::createWindow(WebWindowType type) { diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index 14f3b8b..dda4a6a 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -57,6 +57,7 @@ namespace WebCore { class InspectorClientQt; class InspectorFrontendClientQt; class NotificationPresenterClientQt; + class GeolocationPermissionClientQt; class ResourceHandle; class HitTestResult; class QNetworkReplyHandler; @@ -202,7 +203,8 @@ public: }; enum PermissionDomain { - NotificationsPermissionDomain + NotificationsPermissionDomain, + GeolocationPermissionDomain }; class ViewportHints { @@ -351,7 +353,6 @@ public: public Q_SLOTS: bool shouldInterruptJavaScript(); - bool allowGeolocationRequest(QWebFrame *frame); Q_SIGNALS: void loadStarted(); @@ -424,6 +425,7 @@ private: friend class WebCore::InspectorClientQt; friend class WebCore::InspectorFrontendClientQt; friend class WebCore::NotificationPresenterClientQt; + friend class WebCore::GeolocationPermissionClientQt; friend class WebCore::ResourceHandle; friend class WebCore::QNetworkReplyHandler; friend class DumpRenderTreeSupportQt; diff --git a/WebKit/qt/Api/qwebplugindatabase.cpp b/WebKit/qt/Api/qwebplugindatabase.cpp index 758e257..a7a3b5f 100644 --- a/WebKit/qt/Api/qwebplugindatabase.cpp +++ b/WebKit/qt/Api/qwebplugindatabase.cpp @@ -284,6 +284,10 @@ QList<QWebPluginInfo> QWebPluginDatabase::plugins() const for (unsigned int i = 0; i < plugins.size(); ++i) { PluginPackage* plugin = plugins[i]; +#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) + if (!plugin->ensurePluginLoaded()) + continue; +#endif qwebplugins.append(QWebPluginInfo(plugin)); } diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index edd07da..d88b0da 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -34,6 +34,7 @@ #include "KURL.h" #include "PlatformString.h" #include "IconDatabase.h" +#include "PluginDatabase.h" #include "Image.h" #include "IntSize.h" #include "ApplicationCacheStorage.h" @@ -1093,6 +1094,14 @@ void QWebSettings::enablePersistentStorage(const QString& path) QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true); QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); + +#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) + QFileInfo info(storagePath); + if (info.isDir() && info.isWritable()) { + WebCore::PluginDatabase::setPersistentMetadataCacheEnabled(true); + WebCore::PluginDatabase::setPersistentMetadataCachePath(storagePath); + } +#endif } /*! diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index 10cf60c..1f400cb 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -953,7 +953,11 @@ void QWebView::paintEvent(QPaintEvent *ev) \note If the createWindow() method of the associated page is reimplemented, this method is not called, unless explicitly done so in the reimplementation. - \sa QWebPage::createWindow() + \note In the cases when the window creation is being triggered by JavaScript, apart from + reimplementing this method application must also set the JavaScriptCanOpenWindows attribute + of QWebSettings to true in order for it to get called. + + \sa QWebPage::createWindow(), QWebPage::acceptNavigationRequest() */ QWebView *QWebView::createWindow(QWebPage::WebWindowType type) { diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 9969ebd..996435b 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,232 @@ +2010-09-01 Mahesh Kulkarni <mahesh.kulkarni@nokia.com> + + Reviewed by Laszlo Gombos. + + [Qt] QWebPage::allowGeolocationRequest should be async API + https://bugs.webkit.org/show_bug.cgi?id=41364 + + Provides a new async API for geolocation permission. Using + Notification API approach from qtwebkit. GeolocationPermissionClientQt + maintains list of pending requests from WebCore and intimates them + when client either allowes/denies the request. Also implements + ChromeClientQt::cancelGeolocationPermissionRequestForFrame. + + * Api/qwebpage.cpp: + (QWebPage::setUserPermission): + * Api/qwebpage.h: + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::requestGeolocationPermissionForFrame): + (WebCore::ChromeClientQt::cancelGeolocationPermissionRequestForFrame): + * WebCoreSupport/ChromeClientQt.h: + * WebCoreSupport/GeolocationPermissionClientQt.cpp: Added. + (WebCore::GeolocationPermissionClientQt::geolocationPermissionClient): + (WebCore::GeolocationPermissionClientQt::GeolocationPermissionClientQt): + (WebCore::GeolocationPermissionClientQt::~GeolocationPermissionClientQt): + (WebCore::GeolocationPermissionClientQt::requestGeolocationPermissionForFrame): + (WebCore::GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame): + (WebCore::GeolocationPermissionClientQt::setPermission): + * WebCoreSupport/GeolocationPermissionClientQt.h: Added. + * tests/qwebpage/tst_qwebpage.cpp: + (JSTestPage::requestPermission): + (tst_QWebPage::geolocationRequestJS): + +2010-08-31 Dave Hyatt <hyatt@apple.com> + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=44863, disentangle style recalc from layout, so that + the former can occur in more places without having to do the latter. + + * Api/qwebelement.cpp: + (QWebElement::render): + * Api/qwebframe.cpp: + (QWebFramePrivate::renderRelativeCoords): + +2010-08-31 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] tst_QWebPage::originatingObjectInNetworkRequests() fails on trunk + https://bugs.webkit.org/show_bug.cgi?id=45001 + + Fix the test, we should not use data encoded URL since we are not + setting an URL but setting the substituteData directly. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::originatingObjectInNetworkRequests): + +2010-08-31 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + JSC TimeoutChecker::didTimeOut overflows on ARM + https://bugs.webkit.org/show_bug.cgi?id=38538 + + Re-enabled the test that was skipped for Maemo 5. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::infiniteLoopJS): + +2010-08-30 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r66198. + http://trac.webkit.org/changeset/66198 + https://bugs.webkit.org/show_bug.cgi?id=44856 + + It made tests crash on Qt bot (Requested by Ossy_ on #webkit). + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::inspectorDestroyed): + (WebCore::InspectorClientQt::openInspectorFrontend): + (WebCore::InspectorClientQt::releaseFrontendPage): + (WebCore::InspectorFrontendClientQt::closeWindow): + * WebCoreSupport/InspectorClientQt.h: + +2010-08-28 Daniel Bates <dbates@rim.com> + + Attempt to fix the Qt Windows and Qt Linux Release minimal builds + after changeset 66297 <http://trac.webkit.org/changeset/66297>. + + * Api/qwebplugindatabase.cpp: + (QWebPluginDatabase::plugins): Wrap the call to PluginPackage::ensurePluginLoaded + in #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE). + +2010-08-27 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Antonio Gomes. + + [Qt] tst_QWebView::focusInputTypes() fails on MeeGo Handset with WebKit 2.1 + https://bugs.webkit.org/show_bug.cgi?id=44761 + + Make the test more robust to changes in the execution environment. The click + are now correctly simulated, and the position are determined from the content. + + The test also create the view and page on the stack to avoid the leak when the + test is failing. + + * tests/qwebview/tst_qwebview.cpp: + (tst_QWebView::focusInputTypes): + +2010-08-27 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Cache plugin info to a persistent database + + https://bugs.webkit.org/show_bug.cgi?id=43179 + + Implement a cache of NPAPI plugin metadata. Write the metadata to aa + file that gets rewritten if any plugin is added / removed. Compilation + of the feature is controlled by #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) + + Currently only enabled for Qt UNIX flavors. + + * Api/qwebplugindatabase.cpp: + (QWebPluginDatabase::plugins): Match previous behavior: ensure all returned plugins are loaded. + * Api/qwebsettings.cpp: + (QWebSettings::enablePersistentStorage): Set plugin cache path. + +2010-08-27 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] tst_QWebFrame::inputFieldFocus() fails on MeeGo Handset with QtWebKit 2.1 + https://bugs.webkit.org/show_bug.cgi?id=44703 + + Make the test more robust to changes in the execution environment. + The position where the mouse events are sent is now computed from the element geometry, + this make the test less dependent on the fonts. + + The test now also make sure the window manager mapped the window on screen + before attempting to send the events. + + * tests/qwebframe/tst_qwebframe.cpp: + +2010-08-27 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] tst_QWebFrame::hitTestContent() fails on Meego Handset + https://bugs.webkit.org/show_bug.cgi?id=44701 + + Make the test more robust. The position of the text is not relying + on the size of the fonts anymore. + + * tests/qwebframe/tst_qwebframe.cpp: + +2010-08-26 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Simon Hausmann. + + [Qt] Add support for automatically creating new windows in QWebView + https://bugs.webkit.org/show_bug.cgi?id=29847 + + Improved the documentation of createWindow methods of both QWebView and + QWebPage by mentioning that for any of them be called, QWebSettings' + JavaScriptCanOpenWindows attribute must be set to true. + + * Api/qwebpage.cpp: + * Api/qwebview.cpp: + +2010-08-27 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + REGRESSION: Crash occurs at objc_msgSend when closing a window that is displaying the web inspector + https://bugs.webkit.org/show_bug.cgi?id=44230 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::inspectorDestroyed): + (WebCore::InspectorClientQt::openInspectorFrontend): + (WebCore::InspectorClientQt::releaseFrontendPage): + (WebCore::InspectorFrontendClientQt::closeWindow): + (WebCore::InspectorFrontendClientQt::disconnectFromBackend): + (WebCore::InspectorFrontendClientQt::destroyInspectorView): + (WebCore::InspectorFrontendClientQt::inspectorClientDestroyed): + * WebCoreSupport/InspectorClientQt.h: + +2010-08-26 Girish Ramakrishnan <girish@forwardbias.in> + + Reviewed by Antonio Gomes. + + [Qt] Remove dead code. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::statusbarVisible): + +2010-08-26 Yury Semikhatsky <yurys@chromium.org> + + Unreviewed. Revert r66103 since Qt tests are failing. + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorFrontendClientQt::closeWindow): + * WebCoreSupport/InspectorClientQt.h: + +2010-08-26 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + REGRESSION: Crash occurs at objc_msgSend when closing a window that is displaying the web inspector + https://bugs.webkit.org/show_bug.cgi?id=44230 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorFrontendClientQt::closeWindow): + (WebCore::InspectorFrontendClientQt::disconnectFromBackend): + (WebCore::InspectorFrontendClientQt::destroyInspectorView): + * WebCoreSupport/InspectorClientQt.h: + +2010-08-26 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] tst_QWebFrame::popupFocus() hardcode the element position + https://bugs.webkit.org/show_bug.cgi?id=44674 + + This patch dynamically find the position of the combo element instead + of hardcoding a position to click. + + * tests/qwebframe/tst_qwebframe.cpp: + 2010-08-25 Leo Yang <leo.yang@torchmobile.com.cn> Reviewed by Simon Hausmann. diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index bfce824..8b01d4d 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -41,6 +41,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "GraphicsLayerQt.h" #endif +#include "GeolocationPermissionClientQt.h" #include "HitTestResult.h" #include "Icon.h" #include "NotImplemented.h" @@ -229,7 +230,6 @@ void ChromeClientQt::setStatusbarVisible(bool visible) bool ChromeClientQt::statusbarVisible() { return statusBarVisible; - return false; } @@ -568,10 +568,18 @@ void ChromeClientQt::setCursor(const Cursor& cursor) void ChromeClientQt::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation) { - bool allow = false; +#if ENABLE(GEOLOCATION) QWebFrame* webFrame = QWebFramePrivate::kit(frame); - QMetaObject::invokeMethod(m_webPage, "allowGeolocationRequest", Qt::DirectConnection, Q_RETURN_ARG(bool, allow), Q_ARG(QWebFrame*, webFrame)); - geolocation->setIsAllowed(allow); + GeolocationPermissionClientQt::geolocationPermissionClient()->requestGeolocationPermissionForFrame(webFrame, geolocation); +#endif +} + +void ChromeClientQt::cancelGeolocationPermissionRequestForFrame(Frame* frame, Geolocation* geolocation) +{ +#if ENABLE(GEOLOCATION) + QWebFrame* webFrame = QWebFramePrivate::kit(frame); + GeolocationPermissionClientQt::geolocationPermissionClient()->cancelGeolocationPermissionRequestForFrame(webFrame, geolocation); +#endif } #if USE(ACCELERATED_COMPOSITING) diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h index 55edc50..d18f993 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -168,7 +168,7 @@ namespace WebCore { virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const {} virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*); - virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { } + virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*); virtual bool selectItemWritingDirectionIsNatural(); virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const; diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index b6c3d51..026866c 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -388,7 +388,7 @@ void DumpRenderTreeSupportQt::setMediaType(QWebFrame* frame, const QString& type WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); WebCore::FrameView* view = coreFrame->view(); view->setMediaType(type); - coreFrame->document()->updateStyleSelector(); + coreFrame->document()->styleSelectorChanged(RecalcStyleImmediately); view->layout(); } diff --git a/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp new file mode 100644 index 0000000..5fb9ab7 --- /dev/null +++ b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "GeolocationPermissionClientQt.h" + +#include "Geolocation.h" + +#include "qwebframe.h" +#include "qwebkitglobal.h" +#include "qwebpage.h" + +namespace WebCore { + +#if ENABLE(GEOLOCATION) + +static GeolocationPermissionClientQt* s_geolocationPermission; + +GeolocationPermissionClientQt* GeolocationPermissionClientQt::geolocationPermissionClient() +{ + if (s_geolocationPermission) + return s_geolocationPermission; + + s_geolocationPermission = new GeolocationPermissionClientQt(); + return s_geolocationPermission; +} + +GeolocationPermissionClientQt::GeolocationPermissionClientQt() +{ +} + +GeolocationPermissionClientQt::~GeolocationPermissionClientQt() +{ +} + +void GeolocationPermissionClientQt::requestGeolocationPermissionForFrame(QWebFrame* webFrame, Geolocation* listener) +{ + m_pendingPermissionRequests.insert(webFrame, listener); + + QWebPage* page = webFrame->page(); + emit page->requestPermissionFromUser(webFrame, QWebPage::GeolocationPermissionDomain); +} + + +void GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame(QWebFrame* webFrame, Geolocation* listener) +{ + m_pendingPermissionRequests.remove(webFrame); + + QWebPage* page = webFrame->page(); + emit page->cancelRequestsForPermission(webFrame, QWebPage::GeolocationPermissionDomain); +} + +void GeolocationPermissionClientQt::setPermission(QWebFrame* webFrame, QWebPage::PermissionPolicy permission) +{ + if (!m_pendingPermissionRequests.contains(webFrame)) + return; + + Geolocation* listener = m_pendingPermissionRequests.value(webFrame); + + if (permission == QWebPage::PermissionGranted) + listener->setIsAllowed(true); + else if (permission == QWebPage::PermissionDenied) + listener->setIsAllowed(false); + else + return; + + m_pendingPermissionRequests.remove(webFrame); +} + +#endif // ENABLE(GEOLOCATION) +} diff --git a/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h new file mode 100644 index 0000000..abe9c76 --- /dev/null +++ b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GeolocationPermissionClientQt_h +#define GeolocationPermissionClientQt_h + +#include "Geolocation.h" +#include "qwebpage.h" + +#include <QHash> + +class QWebFrame; +class QWebPage; + +namespace WebCore { + +class GeolocationPermissionClientQt { +public: + GeolocationPermissionClientQt(); + ~GeolocationPermissionClientQt(); + + void requestGeolocationPermissionForFrame(QWebFrame*, Geolocation*); + void cancelGeolocationPermissionRequestForFrame(QWebFrame*, Geolocation*); + void setPermission(QWebFrame*, QWebPage::PermissionPolicy); + + static GeolocationPermissionClientQt* geolocationPermissionClient(); +private: + QHash<QWebFrame*, Geolocation*> m_pendingPermissionRequests; +}; + +} + +#endif diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 83b8600..98ce663 100644 --- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -2678,7 +2678,8 @@ void tst_QWebFrame::popupFocus() QTRY_VERIFY(view.hasFocus()); // open the popup by clicking. check if focus is on the popup - QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(25, 25)); + const QWebElement webCombo = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("select[name=select]")); + QTest::mouseClick(&view, Qt::LeftButton, 0, webCombo.geometry().center()); QObject* webpopup = firstChildByClassName(&view, "QComboBox"); QComboBox* combo = qobject_cast<QComboBox*>(webpopup); QVERIFY(combo != 0); @@ -2696,6 +2697,7 @@ void tst_QWebFrame::inputFieldFocus() view.setHtml("<html><body><input type=\"text\"></input></body></html>"); view.resize(400, 100); view.show(); + QTest::qWaitForWindowShown(&view); view.setFocus(); QTRY_VERIFY(view.hasFocus()); @@ -2703,7 +2705,8 @@ void tst_QWebFrame::inputFieldFocus() int delay = qApp->cursorFlashTime() * 2; // focus the lineedit and check if it blinks - QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(25, 25)); + const QWebElement inputElement = view.page()->mainFrame()->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&view, Qt::LeftButton, 0, inputElement.geometry().center()); m_inputFieldsTestView = &view; view.installEventFilter( this ); QTest::qWait(delay); @@ -2713,13 +2716,14 @@ void tst_QWebFrame::inputFieldFocus() void tst_QWebFrame::hitTestContent() { - QString html("<html><body><p>A paragraph</p><br/><br/><br/><a href=\"about:blank\" target=\"_foo\">link text</a></body></html>"); + QString html("<html><body><p>A paragraph</p><br/><br/><br/><a href=\"about:blank\" target=\"_foo\" id=\"link\">link text</a></body></html>"); QWebPage page; QWebFrame* frame = page.mainFrame(); frame->setHtml(html); page.setViewportSize(QSize(200, 0)); //no height so link is not visible - QWebHitTestResult result = frame->hitTestContent(QPoint(10, 100)); + const QWebElement linkElement = frame->documentElement().findFirst(QLatin1String("a#link")); + QWebHitTestResult result = frame->hitTestContent(linkElement.geometry().center()); QCOMPARE(result.linkText(), QString("link text")); QWebElement link = result.linkElement(); QCOMPARE(link.attribute("target"), QString("_foo")); diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 67e3ecd..9a6c35f 100644 --- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -217,9 +217,12 @@ public slots: bool shouldInterruptJavaScript() { return true; } - bool allowGeolocationRequest(QWebFrame *frame) + void requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain) { - return m_allowGeolocation; + if (m_allowGeolocation) + setUserPermission(frame, domain, PermissionGranted); + else + setUserPermission(frame, domain, PermissionDenied); } public: @@ -234,9 +237,6 @@ private: void tst_QWebPage::infiniteLoopJS() { -#ifdef Q_WS_MAEMO_5 - QSKIP("Test never terminates on Maemo 5 : https://bugs.webkit.org/show_bug.cgi?id=38538", SkipAll); -#endif JSTestPage* newPage = new JSTestPage(m_view); m_view->setPage(newPage); m_view->setHtml(QString("<html><body>test</body></html>"), QUrl()); @@ -247,6 +247,9 @@ void tst_QWebPage::infiniteLoopJS() void tst_QWebPage::geolocationRequestJS() { JSTestPage* newPage = new JSTestPage(m_view); + connect(newPage, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), + newPage, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain))); + newPage->setGeolocationPermission(false); m_view->setPage(newPage); m_view->setHtml(QString("<html><body>test</body></html>"), QUrl()); @@ -2028,7 +2031,7 @@ void tst_QWebPage::originatingObjectInNetworkRequests() m_page->setNetworkAccessManager(networkManager); networkManager->requests.clear(); - m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html," + m_view->setHtml(QString("<frameset cols=\"25%,75%\"><frame src=\"data:text/html," "<head><meta http-equiv='refresh' content='1'></head>foo \">" "<frame src=\"data:text/html,bar\"></frameset>"), QUrl()); QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 57f726d..fd4978d 100644 --- a/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -28,6 +28,7 @@ #include <qnetworkrequest.h> #include <qdiriterator.h> #include <qwebkitversion.h> +#include <qwebelement.h> #include <qwebframe.h> class tst_QWebView : public QObject @@ -52,20 +53,6 @@ private slots: void crashTests(); }; -class WebView : public QWebView -{ - Q_OBJECT - -public: - void fireMouseClick(QPoint point) { - QMouseEvent presEv(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); - QMouseEvent relEv(QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); - QWebView::mousePressEvent(&presEv); - QWebView::mousePressEvent(&relEv); - } - -}; - // This will be called before the first test function is executed. // It is only called once. void tst_QWebView::initTestCase() @@ -245,79 +232,86 @@ void tst_QWebView::microFocusCoordinates() void tst_QWebView::focusInputTypes() { - QWebPage* page = new QWebPage; - WebView* webView = new WebView; - webView->setPage( page ); + QWebView webView; + webView.show(); + QTest::qWaitForWindowShown(&webView); - QCoreApplication::processEvents(); QUrl url("qrc:///resources/input_types.html"); - page->mainFrame()->load(url); - page->mainFrame()->setFocus(); + QWebFrame* const mainFrame = webView.page()->mainFrame(); + mainFrame->load(url); + mainFrame->setFocus(); - QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + QVERIFY(waitForSignal(&webView, SIGNAL(loadFinished(bool)))); // 'text' type - webView->fireMouseClick(QPoint(20, 10)); + QWebElement inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) - QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase); - QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText); + QVERIFY(webView.inputMethodHints() & Qt::ImhNoAutoUppercase); + QVERIFY(webView.inputMethodHints() & Qt::ImhNoPredictiveText); #else - QVERIFY(webView->inputMethodHints() == Qt::ImhNone); + QVERIFY(webView.inputMethodHints() == Qt::ImhNone); #endif - QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field - webView->fireMouseClick(QPoint(20, 60)); - QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); - QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + 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)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=tel]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + 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)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=number]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + 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)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=email]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + 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)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=url]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + 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)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QVERIFY(webView.inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'text' type - webView->fireMouseClick(QPoint(20, 10)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) - QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase); - QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText); + QVERIFY(webView.inputMethodHints() & Qt::ImhNoAutoUppercase); + QVERIFY(webView.inputMethodHints() & Qt::ImhNoPredictiveText); #else - QVERIFY(webView->inputMethodHints() == Qt::ImhNone); + QVERIFY(webView.inputMethodHints() == Qt::ImhNone); #endif - QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field - webView->fireMouseClick(QPoint(20, 60)); - QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); - QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + inputElement = mainFrame->documentElement().findFirst(QLatin1String("input[type=password]")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + 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; - + inputElement = mainFrame->documentElement().findFirst(QLatin1String("textarea")); + QTest::mouseClick(&webView, Qt::LeftButton, 0, inputElement.geometry().center()); + QVERIFY(webView.inputMethodHints() == Qt::ImhNone); + QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); } QTEST_MAIN(tst_QWebView) |