diff options
author | Kristian Monsen <kristianm@google.com> | 2010-07-30 10:46:49 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-08-04 13:01:34 +0100 |
commit | 0617145a89917ae7735fe1c9538688ab9a577df5 (patch) | |
tree | 56206078694427c37ed7bdf27eb5221398b833c0 /WebKit/qt | |
parent | ef1adcdfc805d4d13103f6f15cc5b4d96828a60f (diff) | |
download | external_webkit-0617145a89917ae7735fe1c9538688ab9a577df5.zip external_webkit-0617145a89917ae7735fe1c9538688ab9a577df5.tar.gz external_webkit-0617145a89917ae7735fe1c9538688ab9a577df5.tar.bz2 |
Merge WebKit at r64264 : Initial merge by git.
Change-Id: Ic42bef02efef8217a0f84c47176a9c617c28d1f1
Diffstat (limited to 'WebKit/qt')
21 files changed, 468 insertions, 126 deletions
diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 8fbb8e2..8a94c9b 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -319,8 +319,9 @@ bool QGraphicsWebView::sceneEvent(QEvent* event) || event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchUpdate)) { d->page->event(event); - if (event->isAccepted()) - return true; + + // Always return true so that we'll receive also TouchUpdate and TouchEnd events + return true; } #endif diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index d1741ca..f10d5b4 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -784,6 +784,10 @@ void QWebFrame::load(const QNetworkRequest &req, The \a html is loaded immediately; external objects are loaded asynchronously. + If a script in the \a html runs longer than the default script timeout (currently 10 seconds), + for example due to being blocked by a modal JavaScript alert dialog, this method will return + as soon as possible after the timeout and any subsequent \a html will be loaded asynchronously. + When using this method WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. It is also possible diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h index d83d569..a6be571 100644 --- a/WebKit/qt/Api/qwebkitglobal.h +++ b/WebKit/qt/Api/qwebkitglobal.h @@ -22,9 +22,9 @@ #include <QtCore/qglobal.h> -#define QTWEBKIT_VERSION_STR "2.1.0" +#define QTWEBKIT_VERSION_STR "2.2.0" // QTWEBKIT_VERSION is (major << 16) + (minor << 8) + patch. Similar to Qt. -#define QTWEBKIT_VERSION 0x020100 +#define QTWEBKIT_VERSION 0x020200 // Use: #if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 0, 0)). Similar to Qt. #define QTWEBKIT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 35219a9..fa49293 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -49,6 +49,7 @@ #include "DragController.h" #include "DragData.h" #include "EditorClientQt.h" +#include "SchemeRegistry.h" #include "SecurityOrigin.h" #include "Settings.h" #include "Page.h" @@ -268,11 +269,13 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) WebCore::Font::setCodePath(WebCore::Font::Complex); #endif - chromeClient = new ChromeClientQt(q); - contextMenuClient = new ContextMenuClientQt(); - editorClient = new EditorClientQt(q); - page = new Page(chromeClient, contextMenuClient, editorClient, - new DragClientQt(q), new InspectorClientQt(q), 0, 0, 0, 0); + Page::PageClients pageClients; + pageClients.chromeClient = new ChromeClientQt(q); + pageClients.contextMenuClient = new ContextMenuClientQt(); + pageClients.editorClient = new EditorClientQt(q); + pageClients.dragClient = new DragClientQt(q); + pageClients.inspectorClient = new InspectorClientQt(q); + page = new Page(pageClients); settings = new QWebSettings(page->settings()); @@ -1390,14 +1393,17 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame) } #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) -void QWebPagePrivate::touchEvent(QTouchEvent* event) +bool QWebPagePrivate::touchEvent(QTouchEvent* event) { WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); if (!frame->view()) - return; + return false; - bool accepted = frame->eventHandler()->handleTouchEvent(PlatformTouchEvent(event)); - event->setAccepted(accepted); + // Always accept the QTouchEvent so that we'll receive also TouchUpdate and TouchEnd events + event->setAccepted(true); + + // Return whether the default action was cancelled in the JS event handler + return frame->eventHandler()->handleTouchEvent(PlatformTouchEvent(event)); } #endif @@ -2107,6 +2113,20 @@ bool QWebPage::allowGeolocationRequest(QWebFrame *frame) #endif } +void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, PermissionPolicy policy) +{ + switch (domain) { + case NotificationsPermissionDomain: +#if ENABLE(NOTIFICATIONS) + if (policy == PermissionGranted) + NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame); +#endif + break; + default: + break; + } +} + /*! This function is called whenever WebKit wants to create a new window of the given \a type, for example when a JavaScript program requests to open a document in a new window. @@ -2393,7 +2413,7 @@ bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest & return true; case DelegateExternalLinks: - if (WebCore::SecurityOrigin::shouldTreatURLSchemeAsLocal(request.url().scheme())) + if (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(request.url().scheme())) return true; emit linkClicked(request.url()); return false; @@ -2827,8 +2847,8 @@ bool QWebPage::event(QEvent *ev) case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: - d->touchEvent(static_cast<QTouchEvent*>(ev)); - break; + // Return whether the default action was cancelled in the JS event handler + return d->touchEvent(static_cast<QTouchEvent*>(ev)); #endif #ifndef QT_NO_PROPERTIES case QEvent::DynamicPropertyChange: diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index fcaa302..f0d2438 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -195,6 +195,16 @@ public: WebModalDialog }; + enum PermissionPolicy { + PermissionGranted, + PermissionUnknown, + PermissionDenied + }; + + enum PermissionDomain { + NotificationsPermissionDomain + }; + class ViewportHints { public: ViewportHints(); @@ -290,6 +300,8 @@ public: QMenu *createStandardContextMenu(); + void setUserPermission(QWebFrame* frame, PermissionDomain domain, PermissionPolicy policy); + enum Extension { ChooseMultipleFilesExtension, ErrorPageExtension @@ -371,6 +383,10 @@ Q_SIGNALS: void viewportChangeRequested(const QWebPage::ViewportHints& hints); + void requestPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain); + void checkPermissionFromUser(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy); + void cancelRequestsForPermission(QWebFrame* frame, QWebPage::PermissionDomain domain); + protected: virtual QWebPage *createWindow(WebWindowType type); virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index 54a1523..44ceb87 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -132,7 +132,8 @@ public: bool handleScrolling(QKeyEvent*, WebCore::Frame*); #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) - void touchEvent(QTouchEvent*); + // Returns whether the default action was cancelled in the JS event handler + bool touchEvent(QTouchEvent*); #endif void setInspector(QWebInspector*); diff --git a/WebKit/qt/Api/qwebsecurityorigin.cpp b/WebKit/qt/Api/qwebsecurityorigin.cpp index fe25d2d..e8c8f33 100644 --- a/WebKit/qt/Api/qwebsecurityorigin.cpp +++ b/WebKit/qt/Api/qwebsecurityorigin.cpp @@ -25,6 +25,7 @@ #include "DatabaseTracker.h" #include "KURL.h" +#include "SchemeRegistry.h" #include "SecurityOrigin.h" #include <QStringList> @@ -222,7 +223,7 @@ QList<QWebDatabase> QWebSecurityOrigin::databases() const */ void QWebSecurityOrigin::addLocalScheme(const QString& scheme) { - SecurityOrigin::registerURLSchemeAsLocal(scheme); + SchemeRegistry::registerURLSchemeAsLocal(scheme); } /*! @@ -237,7 +238,7 @@ void QWebSecurityOrigin::addLocalScheme(const QString& scheme) */ void QWebSecurityOrigin::removeLocalScheme(const QString& scheme) { - SecurityOrigin::removeURLSchemeRegisteredAsLocal(scheme); + SchemeRegistry::removeURLSchemeRegisteredAsLocal(scheme); } /*! @@ -251,7 +252,7 @@ void QWebSecurityOrigin::removeLocalScheme(const QString& scheme) QStringList QWebSecurityOrigin::localSchemes() { QStringList list; - const URLSchemesMap& map = SecurityOrigin::localURLSchemes(); + const URLSchemesMap& map = SchemeRegistry::localURLSchemes(); URLSchemesMap::const_iterator end = map.end(); for (URLSchemesMap::const_iterator i = map.begin(); i != end; ++i) { const QString scheme = *i; diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index 4ba6943..edd07da 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -457,12 +457,32 @@ QWebSettings::QWebSettings() d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 0); d->fontSizes.insert(QWebSettings::DefaultFontSize, 16); d->fontSizes.insert(QWebSettings::DefaultFixedFontSize, 13); - d->fontFamilies.insert(QWebSettings::StandardFont, QLatin1String("Arial")); - d->fontFamilies.insert(QWebSettings::FixedFont, QLatin1String("Courier New")); - d->fontFamilies.insert(QWebSettings::SerifFont, QLatin1String("Times New Roman")); - d->fontFamilies.insert(QWebSettings::SansSerifFont, QLatin1String("Arial")); - d->fontFamilies.insert(QWebSettings::CursiveFont, QLatin1String("Arial")); - d->fontFamilies.insert(QWebSettings::FantasyFont, QLatin1String("Arial")); + + QFont defaultFont; + defaultFont.setStyleHint(QFont::Serif); + d->fontFamilies.insert(QWebSettings::StandardFont, defaultFont.defaultFamily()); + d->fontFamilies.insert(QWebSettings::SerifFont, defaultFont.defaultFamily()); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + defaultFont.setStyleHint(QFont::Fantasy); + d->fontFamilies.insert(QWebSettings::FantasyFont, defaultFont.defaultFamily()); + + defaultFont.setStyleHint(QFont::Cursive); + d->fontFamilies.insert(QWebSettings::CursiveFont, defaultFont.defaultFamily()); +#else + d->fontFamilies.insert(QWebSettings::FantasyFont, defaultFont.defaultFamily()); + d->fontFamilies.insert(QWebSettings::CursiveFont, defaultFont.defaultFamily()); +#endif + + defaultFont.setStyleHint(QFont::SansSerif); + d->fontFamilies.insert(QWebSettings::SansSerifFont, defaultFont.defaultFamily()); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + defaultFont.setStyleHint(QFont::Monospace); +#else + defaultFont.setStyleHint(QFont::TypeWriter); +#endif + d->fontFamilies.insert(QWebSettings::FixedFont, defaultFont.defaultFamily()); d->attributes.insert(QWebSettings::AutoLoadImages, true); d->attributes.insert(QWebSettings::DnsPrefetchEnabled, false); diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index 2defdbb..3daa045 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -826,8 +826,9 @@ bool QWebView::event(QEvent *e) || e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchUpdate) { d->page->event(e); - if (e->isAccepted()) - return true; + + // Always return true so that we'll receive also TouchUpdate and TouchEnd events + return true; #endif } else if (e->type() == QEvent::Leave) d->page->event(e); diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index edc8f52..455fd89 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,188 @@ +2010-07-28 Kim Grönholm <kim.1.gronholm@nokia.com> + + Reviewed by Antonio Gomes. + + [Qt] Decouple QTouchEvent's accepted flag from JS prevent default + https://bugs.webkit.org/show_bug.cgi?id=42892 + + Added comments to the touch event handling code. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::sceneEvent): + * Api/qwebpage.cpp: + (QWebPagePrivate::touchEvent): + (QWebPage::event): + * Api/qwebpage_p.h: + * Api/qwebview.cpp: + (QWebView::event): + +2010-07-26 Steve Block <steveblock@google.com> + + Reviewed by Jeremy Orlow. + + Page clients should be passed to Page constructor via structure of pointers + https://bugs.webkit.org/show_bug.cgi?id=42834 + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + +2010-07-27 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Incorrect input method hints + https://bugs.webkit.org/show_bug.cgi?id=43037 + + Properly set or reset all input method hints when + activating input fields. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + * tests/qwebview/tst_qwebview.cpp: + (tst_QWebView::focusInputTypes): Extended unit test to verify that we + reset hints. + +2010-07-27 Kim Grönholm <kim.1.gronholm@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Decouple QTouchEvent's accepted flag from JS prevent default + https://bugs.webkit.org/show_bug.cgi?id=42892 + + We need to always accept the QTouchEvents in order to get TouchUpdate and + TouchEnd events. QWebPage::event() return value is used to indicate + whether the default action was prevented for the touch events. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebView::sceneEvent): + * Api/qwebpage.cpp: + (QWebPagePrivate::touchEvent): + (QWebPage::event): + * Api/qwebpage_p.h: + * Api/qwebview.cpp: + (QWebView::event): + +2010-07-26 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Change default font from sans-serif to serif + + This matches what other ports and browser engines do. + + We now also use QFont's defaultFontFamily() to resolve the + correct fonts for each platform. For Qt >= 4.7 we can take + advantage of the new enums for generic font families. + + * Api/qwebsettings.cpp: + +2009-10-30 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml() + + This ensures that long-running JavaScript (for example due to a modal alert() dialog), + will not trigger a deferred load after only 500ms (the default tokenizer delay) while + still giving a reasonable timeout (10 seconds) to prevent deadlock. + + https://bugs.webkit.org/show_bug.cgi?id=29381 + + * Api/qwebframe.cpp: Document the behaviour + * WebCoreSupport/FrameLoaderClientQt.cpp: set the custom tokenizer delay for substitute loads + * tests/qwebframe/tst_qwebframe.cpp: Add test + +2010-07-23 David Boddie <dboddie@trolltech.com> + + Reviewed by Simon Hausmann. + + Doc: Fixed incorrect QML property type. + + * declarative/qdeclarativewebview.cpp: + +2010-07-23 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Build fix for Qt apps + + Add webkit to QT_CONFIG. qconfig.pri will read qt_webkit_version.pri and + that's how it will pick up webkit in QT_CONFIG. + + * qt_webkit_version.pri: + +2010-07-22 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Laszlo Gombos. + + [Qt] QtWebKit needs public API for Notifications. + https://bugs.webkit.org/show_bug.cgi?id=41413 + + Remove DumpRenderTree private API and introduce new API. + Also add support for informing the UI when a notification request is cancelled. + + * Api/qwebpage.cpp: + (QWebPage::setUserPermission): + * Api/qwebpage.h: + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + * WebCoreSupport/DumpRenderTreeSupportQt.h: + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (WebCore::NotificationPresenterClientQt::requestPermission): + (WebCore::NotificationPresenterClientQt::checkPermission): + (WebCore::NotificationPresenterClientQt::cancelRequestsForPermission): + (WebCore::NotificationPresenterClientQt::allowNotificationForFrame): + (WebCore::NotificationPresenterClientQt::toPage): + (WebCore::NotificationPresenterClientQt::toFrame): + * WebCoreSupport/NotificationPresenterClientQt.h: + +2010-07-22 Jamey Hicks <jamey.hicks@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Enable binding of QObjects to JavaScript environment for inspector frontend + + This patch enables QObjects to be bound to global variables in the + javascript environment of the inspector frontend. This is useful + for writing alternate inspector frontends in javascript which need + additional native functionality. It's a lighter-weight alternative + than using an NPAPI plugin. + + The code which instantiates QWebInspector uses this by setting the + dynamic property "q_inspectorJavaScriptWindowObjects" on the + QWebInspector. The value of this property should be a + QMap<QString,QVariant> mapping global variable name to QObject. + + I have used this to add support for eclipse/chrome remote + debugging in QtTestBrowser. + + https://bugs.webkit.org/show_bug.cgi?id=41995 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientWebPage::InspectorClientWebPage): + (WebCore::InspectorClientWebPage::javaScriptWindowObjectCleared): + (WebCore::InspectorClientQt::openInspectorFrontend): + +2010-07-22 Simon Hausmann <simon.hausmann@nokia.com> + + [Qt] Library versioning. + + 2.1 is branched, trunk will become 2.2. + + * Api/qwebkitglobal.h: + * qt_webkit_version.pri: + +2010-07-21 Brady Eidson <beidson@apple.com> + + Reviewed by Geoffrey Garen. + + Break out "scheme registration" functionality from SecurityOrigin to a SchemeRegistry + https://bugs.webkit.org/show_bug.cgi?id=42783 + + * Api/qwebpage.cpp: + (QWebPage::acceptNavigationRequest): + * Api/qwebsecurityorigin.cpp: + (QWebSecurityOrigin::addLocalScheme): + (QWebSecurityOrigin::removeLocalScheme): + (QWebSecurityOrigin::localSchemes): + 2010-07-20 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org> [Qt] Add API to define device-width and height for use with the viewport meta tag diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index a83e1a5..ddc9d7a 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -70,8 +70,6 @@ using namespace WebCore; -CheckPermissionFunctionType* checkPermissionFunction = 0; -RequestPermissionFunctionType* requestPermissionFunction = 0; QMap<int, QWebScriptWorld*> m_worldMap; DumpRenderTreeSupportQt::DumpRenderTreeSupportQt() @@ -575,20 +573,6 @@ void DumpRenderTreeSupportQt::dumpNotification(bool b) #endif } -void DumpRenderTreeSupportQt::setNotificationsReceiver(QObject* receiver) -{ -#if ENABLE(NOTIFICATIONS) - NotificationPresenterClientQt::notificationPresenter()->setReceiver(receiver); -#endif -} - -void DumpRenderTreeSupportQt::allowNotificationForOrigin(const QString& origin) -{ -#if ENABLE(NOTIFICATIONS) - NotificationPresenterClientQt::notificationPresenter()->allowNotificationForOrigin(origin); -#endif -} - void DumpRenderTreeSupportQt::setMockGeolocationPosition(double latitude, double longitude, double accuracy) { #if ENABLE(GEOLOCATION) @@ -605,16 +589,6 @@ void DumpRenderTreeSupportQt::setMockGeolocationError(int errorCode, const QStri #endif } -void DumpRenderTreeSupportQt::setCheckPermissionFunction(CheckPermissionFunctionType* f) -{ - checkPermissionFunction = f; -} - -void DumpRenderTreeSupportQt::setRequestPermissionFunction(RequestPermissionFunctionType* f) -{ - requestPermissionFunction = f; -} - bool DumpRenderTreeSupportQt::isTargetItem(const QWebHistoryItem& historyItem) { QWebHistoryItem it = historyItem; diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index 188c405..3a92158 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -32,17 +32,6 @@ class QWebPage; class QWebHistoryItem; class QWebScriptWorld; -enum NotificationPermission { - NotificationAllowed, - NotificationNotAllowed, - NotificationDenied -}; - -typedef void (CheckPermissionFunctionType) (QObject* receiver, const QUrl&, NotificationPermission&); -typedef void (RequestPermissionFunctionType) (QObject* receiver, const QString&); - -extern CheckPermissionFunctionType* checkPermissionFunction; -extern RequestPermissionFunctionType* requestPermissionFunction; extern QMap<int, QWebScriptWorld*> m_worldMap; class QWEBKIT_EXPORT DumpRenderTreeSupportQt { @@ -123,13 +112,6 @@ public: static void dumpNotification(bool b); - // These functions should eventually turn into public API - // and the "receiver" concept would go away - static void setNotificationsReceiver(QObject* receiver); - static void allowNotificationForOrigin(const QString& origin); - static void setCheckPermissionFunction(CheckPermissionFunctionType*); - static void setRequestPermissionFunction(RequestPermissionFunctionType*); - static QMap<QString, QWebHistoryItem> getChildHistoryItems(const QWebHistoryItem& historyItem); static bool isTargetItem(const QWebHistoryItem& historyItem); static QString historyItemTarget(const QWebHistoryItem& historyItem); diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 74c8438..54993b1 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -603,20 +603,18 @@ void EditorClientQt::setInputMethodState(bool active) inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode()); if (inputElement) { - if (!active) { - // 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. - active = inputElement->isPasswordField(); - webPageClient->setInputMethodHint(Qt::ImhHiddenText, active); - } else { - // Set input method hints for "number", "tel", "email", and "url" 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()); - webPageClient->setInputMethodHint(Qt::ImhHiddenText, inputElement->isPasswordField()); - } + // 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()); + // 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) + active = true; } #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index fc0f6c3..9fe66d9 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -39,6 +39,7 @@ #include "FrameView.h" #include "DocumentLoader.h" #include "HitTestResult.h" +#include "JSDOMWindowBase.h" #include "MIMETypeRegistry.h" #include "MouseEvent.h" #include "ResourceResponse.h" @@ -879,8 +880,15 @@ bool FrameLoaderClientQt::shouldFallBack(const WebCore::ResourceError&) WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData) { RefPtr<DocumentLoader> loader = DocumentLoader::create(request, substituteData); - if (!deferMainResourceDataLoad || substituteData.isValid()) + if (!deferMainResourceDataLoad || substituteData.isValid()) { loader->setDeferMainResourceDataLoad(false); + // Use the default timeout interval for JS as the HTML tokenizer delay. This ensures + // that long-running JavaScript will still allow setHtml() to be synchronous, while + // still giving a reasonable timeout to prevent deadlock. + double delay = JSDOMWindowBase::commonJSGlobalData()->timeoutChecker.timeoutInterval() / 1000.0f; + m_frame->page()->setCustomHTMLTokenizerTimeDelay(delay); + } else + m_frame->page()->setCustomHTMLTokenizerTimeDelay(-1); return loader.release(); } diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 2cc7e50..e13f6c3 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -44,6 +44,7 @@ #include "qwebview.h" #include <QtCore/QCoreApplication> #include <QtCore/QSettings> +#include <QtCore/QVariant> namespace WebCore { @@ -60,6 +61,7 @@ public: InspectorClientWebPage(QObject* parent = 0) : QWebPage(parent) { + connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(javaScriptWindowObjectCleared())); } QWebPage* createWindow(QWebPage::WebWindowType) @@ -70,6 +72,25 @@ public: view->setAttribute(Qt::WA_DeleteOnClose); return page; } + +public slots: + void javaScriptWindowObjectCleared() + { +#ifndef QT_NO_PROPERTIES + QVariant inspectorJavaScriptWindowObjects = property("_q_inspectorJavaScriptWindowObjects"); + if (!inspectorJavaScriptWindowObjects.isValid()) + return; + QMap<QString, QVariant> javaScriptNameObjectMap = inspectorJavaScriptWindowObjects.toMap(); + QWebFrame* frame = mainFrame(); + QMap<QString, QVariant>::const_iterator it = javaScriptNameObjectMap.constBegin(); + for ( ; it != javaScriptNameObjectMap.constEnd(); ++it) { + QString name = it.key(); + QVariant value = it.value(); + QObject* obj = value.value<QObject*>(); + frame->addToJavaScriptWindowObject(name, obj); + } +#endif + } }; InspectorClientQt::InspectorClientQt(QWebPage* page) @@ -100,6 +121,12 @@ void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*) #endif if (!inspectorUrl.isValid()) inspectorUrl = QUrl("qrc:/webkit/inspector/inspector.html"); + +#ifndef QT_NO_PROPERTIES + QVariant inspectorJavaScriptWindowObjects = inspector->property("_q_inspectorJavaScriptWindowObjects"); + if (inspectorJavaScriptWindowObjects.isValid()) + inspectorPage->setProperty("_q_inspectorJavaScriptWindowObjects", inspectorJavaScriptWindowObjects); +#endif inspectorView->page()->mainFrame()->load(inspectorUrl); m_inspectedWebPage->d->inspectorFrontend = inspectorView; inspector->d->setFrontend(inspectorView); diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index ee69103..477e205 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -36,11 +36,14 @@ #include "DumpRenderTreeSupportQt.h" #include "EventNames.h" #include "KURL.h" +#include "Page.h" #include "QtPlatformPlugin.h" #include "ScriptExecutionContext.h" #include "SecurityOrigin.h" +#include "qwebframe_p.h" #include "qwebkitglobal.h" +#include "qwebpage.h" #include <QtGui> namespace WebCore { @@ -259,53 +262,77 @@ void NotificationPresenterClientQt::requestPermission(ScriptExecutionContext* co if (dumpNotification) printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData()); - QString originString = context->securityOrigin()->toString(); - QHash<QString, QList<RefPtr<VoidCallback> > >::iterator iter = m_pendingPermissionRequests.find(originString); + QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context); if (iter != m_pendingPermissionRequests.end()) - iter.value().append(callback); + iter.value().m_callbacks.append(callback); else { - QList<RefPtr<VoidCallback> > callbacks; RefPtr<VoidCallback> cb = callback; - callbacks.append(cb); - m_pendingPermissionRequests.insert(originString, callbacks); - if (requestPermissionFunction) - requestPermissionFunction(m_receiver, originString); + CallbacksInfo info; + info.m_frame = toFrame(context); + info.m_callbacks.append(cb); + m_pendingPermissionRequests.insert(context, info); + + if (toPage(context) && toFrame(context)) { + m_pendingPermissionRequests.insert(context, info); + emit toPage(context)->requestPermissionFromUser(toFrame(context), QWebPage::NotificationsPermissionDomain); + } } } NotificationPresenter::Permission NotificationPresenterClientQt::checkPermission(ScriptExecutionContext* context) { - NotificationPermission permission = NotificationNotAllowed; - QString origin = context->url().string(); - if (checkPermissionFunction) - checkPermissionFunction(m_receiver, origin, permission); - switch (permission) { - case NotificationAllowed: + QWebPage::PermissionPolicy policy = QWebPage::PermissionUnknown; + if (toPage(context) && toFrame(context)) + emit toPage(context)->checkPermissionFromUser(toFrame(context), QWebPage::NotificationsPermissionDomain, policy); + + switch (policy) { + case QWebPage::PermissionGranted: return NotificationPresenter::PermissionAllowed; - case NotificationNotAllowed: + case QWebPage::PermissionUnknown: return NotificationPresenter::PermissionNotAllowed; - case NotificationDenied: + case QWebPage::PermissionDenied: return NotificationPresenter::PermissionDenied; } ASSERT_NOT_REACHED(); return NotificationPresenter::PermissionNotAllowed; } -void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionContext*) +void NotificationPresenterClientQt::cancelRequestsForPermission(ScriptExecutionContext* context) { - // FIXME: This will be implemented for https://bugs.webkit.org/show_bug.cgi?id=41413 - // to avoid adding and removing new private API + QHash<ScriptExecutionContext*, CallbacksInfo >::iterator iter = m_pendingPermissionRequests.find(context); + if (iter == m_pendingPermissionRequests.end()) + return; + + QWebFrame* frame = iter.value().m_frame; + if (!frame) + return; + QWebPage* page = frame->page(); + m_pendingPermissionRequests.erase(iter); + + if (!page) + return; + + if (dumpNotification) + printf("DESKTOP NOTIFICATION PERMISSION REQUEST CANCELLED: %s\n", QString(context->securityOrigin()->toString()).toUtf8().constData()); + + emit page->cancelRequestsForPermission(frame, QWebPage::NotificationsPermissionDomain); } -void NotificationPresenterClientQt::allowNotificationForOrigin(const QString& origin) +void NotificationPresenterClientQt::allowNotificationForFrame(QWebFrame* frame) { - 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); + QHash<ScriptExecutionContext*, CallbacksInfo>::iterator iter = m_pendingPermissionRequests.begin(); + while (iter != m_pendingPermissionRequests.end()) { + if (toFrame(iter.key()) == frame) + break; } + + if (iter == m_pendingPermissionRequests.end()) + return; + + QList<RefPtr<VoidCallback> >& callbacks = iter.value().m_callbacks; + for (int i = 0; i < callbacks.size(); i++) + callbacks.at(i)->handleEvent(); + m_pendingPermissionRequests.remove(iter.key()); } void NotificationPresenterClientQt::sendEvent(Notification* notification, const AtomicString& eventName) @@ -362,6 +389,34 @@ void NotificationPresenterClientQt::dumpShowText(Notification* notification) } } +QWebPage* NotificationPresenterClientQt::toPage(ScriptExecutionContext* context) +{ + if (!context || context->isWorkerContext()) + return 0; + + Document* document = static_cast<Document*>(context); + if (!document) + return 0; + + Page* page = document->page(); + if (!page || !page->mainFrame()) + return 0; + + return QWebFramePrivate::kit(page->mainFrame())->page(); +} + +QWebFrame* NotificationPresenterClientQt::toFrame(ScriptExecutionContext* context) +{ + if (!context || context->isWorkerContext()) + return 0; + + Document* document = static_cast<Document*>(context); + if (!document || !document->frame()) + return 0; + + return QWebFramePrivate::kit(document->frame()); +} + #endif // ENABLE(NOTIFICATIONS) } diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index b99393b..e8481d4 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -42,6 +42,9 @@ #include <QMultiHash> #include <QSystemTrayIcon> +class QWebFrame; +class QWebPage; + namespace WebCore { class Document; @@ -90,12 +93,10 @@ public: void cancel(NotificationWrapper*); - void allowNotificationForOrigin(const QString& origin); + void allowNotificationForFrame(QWebFrame*); static bool dumpNotification; - void setReceiver(QObject* receiver) { m_receiver = receiver; } - void addClient() { m_clientCount++; } void removeClient(); static NotificationPresenterClientQt* notificationPresenter(); @@ -109,11 +110,17 @@ private: void detachNotification(Notification*); void dumpReplacedIdText(Notification*); void dumpShowText(Notification*); + QWebPage* toPage(ScriptExecutionContext*); + QWebFrame* toFrame(ScriptExecutionContext*); int m_clientCount; - QHash<QString, QList<RefPtr<VoidCallback> > > m_pendingPermissionRequests; + struct CallbacksInfo { + QWebFrame* m_frame; + QList<RefPtr<VoidCallback> > m_callbacks; + }; + QHash<ScriptExecutionContext*, CallbacksInfo > m_pendingPermissionRequests; + NotificationsQueue m_notifications; - QObject* m_receiver; QtPlatformPlugin m_platformPlugin; }; diff --git a/WebKit/qt/declarative/qdeclarativewebview.cpp b/WebKit/qt/declarative/qdeclarativewebview.cpp index 0342c9f..9dcba60 100644 --- a/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -612,7 +612,7 @@ QAction* QDeclarativeWebView::stopAction() const #endif // QT_NO_ACTION /*! - \qmlproperty real WebView::title + \qmlproperty string WebView::title This property holds the title of the web page currently viewed By default, this property contains an empty string. diff --git a/WebKit/qt/qt_webkit_version.pri b/WebKit/qt/qt_webkit_version.pri index 1656f2d..ca6299a 100644 --- a/WebKit/qt/qt_webkit_version.pri +++ b/WebKit/qt/qt_webkit_version.pri @@ -1,4 +1,5 @@ -QT_WEBKIT_VERSION = 4.8.0 +QT_WEBKIT_VERSION = 4.9.0 QT_WEBKIT_MAJOR_VERSION = 4 -QT_WEBKIT_MINOR_VERSION = 8 +QT_WEBKIT_MINOR_VERSION = 9 QT_WEBKIT_PATCH_VERSION = 0 +QT_CONFIG *= webkit diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 3d03157..b208447 100644 --- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -601,6 +601,7 @@ private slots: void setHtml(); void setHtmlWithResource(); void setHtmlWithBaseURL(); + void setHtmlWithJSAlert(); void ipv6HostEncoding(); void metaData(); #if !defined(Q_WS_MAEMO_5) @@ -2555,6 +2556,33 @@ void tst_QWebFrame::setHtmlWithBaseURL() QCOMPARE(m_view->page()->history()->count(), 0); } +class MyPage : public QWebPage +{ +public: + MyPage() : QWebPage(), alerts(0) {} + int alerts; + +protected: + virtual void javaScriptAlert(QWebFrame*, const QString& msg) + { + alerts++; + QCOMPARE(msg, QString("foo")); + // Should not be enough to trigger deferred loading, since we've upped the HTML + // tokenizer delay in the Qt frameloader. See HTMLTokenizer::continueProcessing() + QTest::qWait(1000); + } +}; + +void tst_QWebFrame::setHtmlWithJSAlert() +{ + QString html("<html><head></head><body><script>alert('foo');</script><p>hello world</p></body></html>"); + MyPage page; + m_view->setPage(&page); + page.mainFrame()->setHtml(html); + QCOMPARE(page.alerts, 1); + QCOMPARE(m_view->page()->mainFrame()->toHtml(), html); +} + class TestNetworkManager : public QNetworkAccessManager { public: diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 835ad82..5dc5e41 100644 --- a/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -267,23 +267,36 @@ void tst_QWebView::focusInputTypes() // 'password' field webView->fireMouseClick(QPoint(20, 60)); - QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText); + QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); // 'tel' field webView->fireMouseClick(QPoint(20, 110)); - QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly); + QVERIFY(webView->inputMethodHints() == Qt::ImhDialableCharactersOnly); // 'number' field webView->fireMouseClick(QPoint(20, 160)); - QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly); + QVERIFY(webView->inputMethodHints() == Qt::ImhDigitsOnly); // 'email' field webView->fireMouseClick(QPoint(20, 210)); - QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly); + QVERIFY(webView->inputMethodHints() == Qt::ImhEmailCharactersOnly); // 'url' field webView->fireMouseClick(QPoint(20, 260)); - QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly); + QVERIFY(webView->inputMethodHints() == Qt::ImhUrlCharactersOnly); + + // 'password' field + webView->fireMouseClick(QPoint(20, 60)); + QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + + // 'text' type + webView->fireMouseClick(QPoint(20, 10)); +#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); +#else + QVERIFY(webView->inputMethodHints() == Qt::ImhNone); +#endif delete webView; |