diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
8 files changed, 110 insertions, 12 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 86af62ea6..b4deaac84 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -1144,3 +1144,13 @@ double WKPreferencesGetIncrementalRenderingSuppressionTimeout(WKPreferencesRef p { return toAPI(toImpl(preferencesRef)->incrementalRenderingSuppressionTimeout()); } + +void WKPreferencesSetSpatialNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setSpatialNavigationEnabled(enabled); +} + +bool WKPreferencesGetSpatialNavigationEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->spatialNavigationEnabled(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h index bf36bb60e..a9865d15f 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h @@ -240,6 +240,10 @@ WK_EXPORT bool WKPreferencesGetQTKitEnabled(WKPreferencesRef preferencesRef); WK_EXPORT void WKPreferencesSetAsynchronousSpellCheckingEnabled(WKPreferencesRef preferencesRef, bool enabled); WK_EXPORT bool WKPreferencesGetAsynchronousSpellCheckingEnabled(WKPreferencesRef preferencesRef); +// Defaults to false. +WK_EXPORT void WKPreferencesSetSpatialNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetSpatialNavigationEnabled(WKPreferencesRef preferencesRef); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index 11ebb4f81..bc2d5d21c 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -621,6 +621,7 @@ void QQuickWebViewPrivate::didRelaunchProcess() updateViewportSize(); updateUserScripts(); + updateUserStyleSheets(); updateSchemeDelegates(); } @@ -874,27 +875,32 @@ void QQuickWebViewPrivate::setNavigatorQtObjectEnabled(bool enabled) WKPagePostMessageToInjectedBundle(webPage.get(), messageName, wkEnabled.get()); } -static WKRetainPtr<WKStringRef> readUserScript(const QUrl& url) +static WKRetainPtr<WKStringRef> readUserFile(const QUrl& url, const char* userFileType) { + if (!url.isValid()) { + qWarning("QQuickWebView: Couldn't open '%s' as %s because URL is invalid.", qPrintable(url.toString()), userFileType); + return 0; + } + QString path; if (url.isLocalFile()) path = url.toLocalFile(); else if (url.scheme() == QLatin1String("qrc")) path = QStringLiteral(":") + url.path(); else { - qWarning("QQuickWebView: Couldn't open '%s' as user script because only file:/// and qrc:/// URLs are supported.", qPrintable(url.toString())); + qWarning("QQuickWebView: Couldn't open '%s' as %s because only file:/// and qrc:/// URLs are supported.", qPrintable(url.toString()), userFileType); return 0; } QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qWarning("QQuickWebView: Couldn't open '%s' as user script due to error '%s'.", qPrintable(url.toString()), qPrintable(file.errorString())); + qWarning("QQuickWebView: Couldn't open '%s' as %s due to error '%s'.", qPrintable(url.toString()), userFileType, qPrintable(file.errorString())); return 0; } QByteArray contents = file.readAll(); if (contents.isEmpty()) - qWarning("QQuickWebView: Ignoring '%s' as user script because file is empty.", qPrintable(url.toString())); + qWarning("QQuickWebView: Ignoring '%s' as %s because file is empty.", qPrintable(url.toString()), userFileType); return adoptWK(WKStringCreateWithUTF8CString(contents.constData())); } @@ -905,17 +911,25 @@ void QQuickWebViewPrivate::updateUserScripts() // each Page/WebView pair we create. WKPageGroupRemoveAllUserScripts(pageGroup.get()); - for (unsigned i = 0; i < userScripts.size(); ++i) { - const QUrl& url = userScripts.at(i); - if (!url.isValid()) { - qWarning("QQuickWebView: Couldn't open '%s' as user script because URL is invalid.", qPrintable(url.toString())); + foreach (const QUrl& url, userScripts) { + WKRetainPtr<WKStringRef> contents = readUserFile(url, "user script"); + if (!contents || WKStringIsEmpty(contents.get())) continue; - } + WKPageGroupAddUserScript(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly, kWKInjectAtDocumentEnd); + } +} + +void QQuickWebViewPrivate::updateUserStyleSheets() +{ + // This feature works per-WebView because we keep an unique page group for + // each Page/WebView pair we create. + WKPageGroupRemoveAllUserStyleSheets(pageGroup.get()); - WKRetainPtr<WKStringRef> contents = readUserScript(url); + foreach (const QUrl& url, userStyleSheets) { + WKRetainPtr<WKStringRef> contents = readUserFile(url, "user style sheet"); if (!contents || WKStringIsEmpty(contents.get())) continue; - WKPageGroupAddUserScript(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly, kWKInjectAtDocumentEnd); + WKPageGroupAddUserStyleSheet(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly); } } @@ -1524,6 +1538,22 @@ void QQuickWebViewExperimental::setUserScripts(const QList<QUrl>& userScripts) emit userScriptsChanged(); } +QList<QUrl> QQuickWebViewExperimental::userStyleSheets() const +{ + Q_D(const QQuickWebView); + return d->userStyleSheets; +} + +void QQuickWebViewExperimental::setUserStyleSheets(const QList<QUrl>& userStyleSheets) +{ + Q_D(QQuickWebView); + if (d->userStyleSheets == userStyleSheets) + return; + d->userStyleSheets = userStyleSheets; + d->updateUserStyleSheets(); + emit userStyleSheetsChanged(); +} + QUrl QQuickWebViewExperimental::remoteInspectorUrl() const { #if ENABLE(INSPECTOR_SERVER) diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index 8604dead2..1daf5db0a 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -281,6 +281,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject { Q_PROPERTY(QQmlListProperty<QQuickUrlSchemeDelegate> urlSchemeDelegates READ schemeDelegates) Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged) Q_PROPERTY(QList<QUrl> userScripts READ userScripts WRITE setUserScripts NOTIFY userScriptsChanged) + Q_PROPERTY(QList<QUrl> userStyleSheets READ userStyleSheets WRITE setUserStyleSheets NOTIFY userStyleSheetsChanged) Q_PROPERTY(QUrl remoteInspectorUrl READ remoteInspectorUrl NOTIFY remoteInspectorUrlChanged FINAL) #ifdef HAVE_WEBCHANNEL Q_PROPERTY(QQmlWebChannel* webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged) @@ -331,6 +332,8 @@ public: void setDeviceHeight(int); QList<QUrl> userScripts() const; void setUserScripts(const QList<QUrl>& userScripts); + QList<QUrl> userStyleSheets() const; + void setUserStyleSheets(const QList<QUrl>& userScripts); QUrl remoteInspectorUrl() const; QWebKitTest* test(); @@ -396,6 +399,7 @@ Q_SIGNALS: void enterFullScreenRequested(); void exitFullScreenRequested(); void userScriptsChanged(); + void userStyleSheetsChanged(); void preferredMinimumContentsWidthChanged(); void remoteInspectorUrlChanged(); void textFound(int matchCount); diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index f09c16e90..a7358b5cf 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -122,6 +122,7 @@ public: bool transparentBackground() const; void setNavigatorQtObjectEnabled(bool); void updateUserScripts(); + void updateUserStyleSheets(); void updateSchemeDelegates(); QPointF contentPos() const; @@ -214,6 +215,7 @@ protected: QQmlComponent* colorChooser; QList<QUrl> userScripts; + QList<QUrl> userStyleSheets; bool m_betweenLoadCommitAndFirstFrame; bool m_useDefaultContentItemSize; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp index 26eb944e9..edca4c901 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp @@ -79,6 +79,10 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute return WKPreferencesGetCaretBrowsingEnabled(preferencesRef); case NotificationsEnabled: return WKPreferencesGetNotificationsEnabled(preferencesRef); + case SpatialNavigationEnabled: + return WKPreferencesGetSpatialNavigationEnabled(preferencesRef); + case LinksIncludedInFocusChain: + return WKPreferencesGetTabsToLinks(preferencesRef); case UniversalAccessFromFileURLsAllowed: return WKPreferencesGetUniversalAccessFromFileURLsAllowed(preferencesRef); case FileAccessFromFileURLsAllowed: @@ -149,6 +153,12 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a case NotificationsEnabled: WKPreferencesSetNotificationsEnabled(preferencesRef, enable); break; + case SpatialNavigationEnabled: + WKPreferencesSetSpatialNavigationEnabled(preferencesRef, enable); + break; + case LinksIncludedInFocusChain: + WKPreferencesSetTabsToLinks(preferencesRef, enable); + break; case UniversalAccessFromFileURLsAllowed: WKPreferencesSetUniversalAccessFromFileURLsAllowed(preferencesRef, enable); break; @@ -604,6 +614,32 @@ void QWebPreferences::setFileAccessFromFileURLsAllowed(bool enable) emit fileAccessFromFileURLsAllowedChanged(); } +bool QWebPreferences::spatialNavigationEnabled() const +{ + return d->testAttribute(QWebPreferencesPrivate::SpatialNavigationEnabled); +} + +void QWebPreferences::setSpatialNavigationEnabled(bool enable) +{ + if (spatialNavigationEnabled() == enable) + return; + d->setAttribute(QWebPreferencesPrivate::SpatialNavigationEnabled, enable); + emit spatialNavigationEnabledChanged(); +} + +bool QWebPreferences::linksIncludedInFocusChain() const +{ + return d->testAttribute(QWebPreferencesPrivate::LinksIncludedInFocusChain); +} + +void QWebPreferences::setLinksIncludedInFocusChain(bool enable) +{ + if (linksIncludedInFocusChain() == enable) + return; + d->setAttribute(QWebPreferencesPrivate::LinksIncludedInFocusChain, enable); + emit linksIncludedInFocusChainChanged(); +} + QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences) { return preferences->d; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h index 9c503d431..08c4df2d8 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h @@ -49,6 +49,8 @@ public: Q_PROPERTY(bool notificationsEnabled READ notificationsEnabled WRITE setNotificationsEnabled NOTIFY notificationsEnabledChanged FINAL) Q_PROPERTY(bool universalAccessFromFileURLsAllowed READ universalAccessFromFileURLsAllowed WRITE setUniversalAccessFromFileURLsAllowed NOTIFY universalAccessFromFileURLsAllowedChanged FINAL) Q_PROPERTY(bool fileAccessFromFileURLsAllowed READ fileAccessFromFileURLsAllowed WRITE setFileAccessFromFileURLsAllowed NOTIFY fileAccessFromFileURLsAllowedChanged FINAL) + Q_PROPERTY(bool spatialNavigationEnabled READ spatialNavigationEnabled WRITE setSpatialNavigationEnabled NOTIFY spatialNavigationEnabledChanged FINAL) + Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain NOTIFY linksIncludedInFocusChainChanged FINAL) Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL) Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL) @@ -115,6 +117,12 @@ public: bool fileAccessFromFileURLsAllowed() const; void setFileAccessFromFileURLsAllowed(bool enable); + bool spatialNavigationEnabled() const; + void setSpatialNavigationEnabled(bool enable); + + bool linksIncludedInFocusChain() const; + void setLinksIncludedInFocusChain(bool enable); + QString standardFontFamily() const; void setStandardFontFamily(const QString& family); @@ -159,6 +167,8 @@ Q_SIGNALS: void webAudioEnabledChanged(); void caretBrowsingEnabledChanged(); void notificationsEnabledChanged(); + void spatialNavigationEnabledChanged(); + void linksIncludedInFocusChainChanged(); void universalAccessFromFileURLsAllowedChanged(); void fileAccessFromFileURLsAllowedChanged(); diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h index 844fd5b4e..f978a5bd2 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h @@ -43,7 +43,9 @@ public: CaretBrowsingEnabled, NotificationsEnabled, UniversalAccessFromFileURLsAllowed, - FileAccessFromFileURLsAllowed + FileAccessFromFileURLsAllowed, + SpatialNavigationEnabled, + LinksIncludedInFocusChain }; enum FontFamily { |