summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Binner <stephan.binner@basyskom.com>2015-03-04 12:39:29 +0100
committerStephan Binner <stephan.binner@basyskom.com>2015-03-04 13:43:49 +0000
commit9d1a77b5be56a6a1dade613573eaeea63070969f (patch)
tree932425567b5f7240b4dcf811e90c89cb5ae6518d
parent96f4439589d9385dd10f5e6dc1fa225b17d2eec5 (diff)
Enable building Qt WebEngine without accessiblity enabled.
This adds guards that for QT_NO_ACCESSIBILITY being not defined around the code that uses accessibility types. It disables the quicknanobrowser and quicktestbrowser examples which need Qt QuickControls, which has a hard dependency to accessibility being enabled. Backport of d95b9295c970401939d2779cbdc9e2a8c7965277 from 5.5 Change-Id: I2a2a0a6196fcb3baa39603d9c929183b454f39ed Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
-rw-r--r--examples/webengine/quicknanobrowser/quicknanobrowser.pro2
-rw-r--r--src/core/browser_accessibility_manager_qt.cpp6
-rw-r--r--src/core/browser_accessibility_manager_qt.h2
-rw-r--r--src/core/browser_accessibility_qt.cpp4
-rw-r--r--src/core/browser_accessibility_qt.h3
-rw-r--r--src/core/render_widget_host_view_qt.cpp13
-rw-r--r--src/core/render_widget_host_view_qt.h6
-rw-r--r--src/core/web_contents_adapter.cpp2
-rw-r--r--src/core/web_contents_adapter_client.h2
-rw-r--r--src/webengine/api/qquickwebengineview.cpp12
-rw-r--r--src/webengine/api/qquickwebengineview_p.h2
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h5
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp3
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h2
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h2
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp7
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h3
-rw-r--r--tests/quicktestbrowser/quicktestbrowser.pro2
18 files changed, 73 insertions, 5 deletions
diff --git a/examples/webengine/quicknanobrowser/quicknanobrowser.pro b/examples/webengine/quicknanobrowser/quicknanobrowser.pro
index 3628b817..a8e57b0a 100644
--- a/examples/webengine/quicknanobrowser/quicknanobrowser.pro
+++ b/examples/webengine/quicknanobrowser/quicknanobrowser.pro
@@ -1,3 +1,5 @@
+requires(contains(QT_CONFIG, accessibility))
+
TEMPLATE = app
TARGET = quicknanobrowser
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp
index 28d0dd7e..67298663 100644
--- a/src/core/browser_accessibility_manager_qt.cpp
+++ b/src/core/browser_accessibility_manager_qt.cpp
@@ -45,9 +45,14 @@ namespace content {
BrowserAccessibility *BrowserAccessibilityFactoryQt::Create()
{
+#ifndef QT_NO_ACCESSIBILITY
return new BrowserAccessibilityQt();
+#else
+ return 0;
+#endif // QT_NO_ACCESSIBILITY
}
+#ifndef QT_NO_ACCESSIBILITY
BrowserAccessibilityManagerQt::BrowserAccessibilityManagerQt(
QObject* parentObject,
const ui::AXTreeUpdate& initialTree,
@@ -131,5 +136,6 @@ void BrowserAccessibilityManagerQt::NotifyAccessibilityEvent(ui::AXEvent event_t
break;
}
}
+#endif // QT_NO_ACCESSIBILITY
}
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index 5d8498d0..49b3af3b 100644
--- a/src/core/browser_accessibility_manager_qt.h
+++ b/src/core/browser_accessibility_manager_qt.h
@@ -38,6 +38,7 @@
#define BROWSER_ACCESSIBILITY_MANAGER_QT_H
#include "content/browser/accessibility/browser_accessibility_manager.h"
+#ifndef QT_NO_ACCESSIBILITY
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
@@ -74,4 +75,5 @@ private:
}
+#endif // QT_NO_ACCESSIBILITY
#endif
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index b5cd26f2..4b8e97a3 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -40,6 +40,8 @@
#include "browser_accessibility_qt.h"
+#ifndef QT_NO_ACCESSIBILITY
+
#include "third_party/WebKit/public/web/WebAXEnums.h"
#include "ui/accessibility/ax_node_data.h"
@@ -898,3 +900,5 @@ void BrowserAccessibilityQt::modelChange(QAccessibleTableModelChangeEvent *)
}
} // namespace content
+
+#endif // QT_NO_ACCESSIBILITY
diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h
index db190ffc..e87b5d8f 100644
--- a/src/core/browser_accessibility_qt.h
+++ b/src/core/browser_accessibility_qt.h
@@ -38,6 +38,8 @@
#define BROWSER_ACCESSIBILITY_QT_H
#include <QtGui/qaccessible.h>
+
+#ifndef QT_NO_ACCESSIBILITY
#include "content/browser/accessibility/browser_accessibility.h"
namespace content {
@@ -145,4 +147,5 @@ public:
}
+#endif // QT_NO_ACCESSIBILITY
#endif
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index c221e94e..18d64e84 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -198,15 +198,18 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget
, m_initPending(false)
{
m_host->SetView(this);
-
+#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
if (QAccessible::isActive())
content::BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility();
+#endif // QT_NO_ACCESSIBILITY
}
RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
{
+#ifndef QT_NO_ACCESSIBILITY
QAccessible::removeActivationObserver(this);
+#endif // QT_NO_ACCESSIBILITY
}
void RenderWidgetHostViewQt::setDelegate(RenderWidgetHostViewQtDelegate* delegate)
@@ -296,6 +299,7 @@ gfx::NativeViewAccessible RenderWidgetHostViewQt::GetNativeViewAccessible()
void RenderWidgetHostViewQt::CreateBrowserAccessibilityManagerIfNeeded()
{
+#ifndef QT_NO_ACCESSIBILITY
if (GetBrowserAccessibilityManager())
return;
@@ -303,6 +307,9 @@ void RenderWidgetHostViewQt::CreateBrowserAccessibilityManagerIfNeeded()
m_adapterClient->accessibilityParentObject(),
content::BrowserAccessibilityManagerQt::GetEmptyDocument(),
this));
+#else
+ return 0;
+#endif // QT_NO_ACCESSIBILITY
}
// Set focus to the associated View component.
@@ -953,6 +960,7 @@ void RenderWidgetHostViewQt::AccessibilityFatalError()
SetBrowserAccessibilityManager(NULL);
}
+#ifndef QT_NO_ACCESSIBILITY
void RenderWidgetHostViewQt::accessibilityActiveChanged(bool active)
{
if (active)
@@ -960,6 +968,7 @@ void RenderWidgetHostViewQt::accessibilityActiveChanged(bool active)
else
content::BrowserAccessibilityStateImpl::GetInstance()->DisableAccessibility();
}
+#endif // QT_NO_ACCESSIBILITY
void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
{
@@ -1042,6 +1051,7 @@ void RenderWidgetHostViewQt::handleFocusEvent(QFocusEvent *ev)
}
}
+#ifndef QT_NO_ACCESSIBILITY
QAccessibleInterface *RenderWidgetHostViewQt::GetQtAccessible()
{
// Assume we have a screen reader doing stuff
@@ -1051,6 +1061,7 @@ QAccessibleInterface *RenderWidgetHostViewQt::GetQtAccessible()
content::BrowserAccessibilityQt *accQt = static_cast<content::BrowserAccessibilityQt*>(acc);
return accQt;
}
+#endif // QT_NO_ACCESSIBILITY
void RenderWidgetHostViewQt::didFirstVisuallyNonEmptyLayout()
{
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index d4a3ff24..fac7efd1 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -50,6 +50,7 @@
#include <QRect>
#include <QtGlobal>
#include <QtGui/qaccessible.h>
+#include <QtGui/QTouchEvent>
#include "delegated_frame_node.h"
@@ -59,7 +60,6 @@ class QFocusEvent;
class QHoverEvent;
class QKeyEvent;
class QMouseEvent;
-class QTouchEvent;
class QVariant;
class QWheelEvent;
class QAccessibleInterface;
@@ -93,7 +93,9 @@ class RenderWidgetHostViewQt
, public RenderWidgetHostViewQtDelegateClient
, public content::BrowserAccessibilityDelegate
, public base::SupportsWeakPtr<RenderWidgetHostViewQt>
+#ifndef QT_NO_ACCESSIBILITY
, public QAccessible::ActivationObserver
+#endif // QT_NO_ACCESSIBILITY
{
public:
RenderWidgetHostViewQt(content::RenderWidgetHost* widget);
@@ -213,9 +215,11 @@ public:
virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds) const Q_DECL_OVERRIDE { return gfx::Point(); }
virtual void AccessibilityHitTest(const gfx::Point& point) Q_DECL_OVERRIDE { }
virtual void AccessibilityFatalError() Q_DECL_OVERRIDE;
+#ifndef QT_NO_ACCESSIBILITY
virtual void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
QAccessibleInterface *GetQtAccessible();
+#endif // QT_NO_ACCESSIBILITY
void didFirstVisuallyNonEmptyLayout();
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 3f223f73..e41acd07 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -628,12 +628,14 @@ void WebContentsAdapter::enableInspector(bool enable)
ContentBrowserClientQt::Get()->enableInspector(enable);
}
+#ifndef QT_NO_ACCESSIBILITY
QAccessibleInterface *WebContentsAdapter::browserAccessible()
{
Q_D(const WebContentsAdapter);
RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt*>(d->webContents->GetRenderWidgetHostView());
return rwhv ? rwhv->GetQtAccessible() : Q_NULLPTR;
}
+#endif // QT_NO_ACCESSIBILITY
void WebContentsAdapter::runJavaScript(const QString &javaScript)
{
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 8fd401fe..df189806 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -168,7 +168,9 @@ public:
virtual void passOnFocus(bool reverse) = 0;
// returns the last QObject (QWidget/QQuickItem) based object in the accessibility
// hierarchy before going into the BrowserAccessibility tree
+#ifndef QT_NO_ACCESSIBILITY
virtual QObject *accessibilityParentObject() = 0;
+#endif // QT_NO_ACCESSIBILITY
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0;
virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) = 0;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 3497c16a..a35cfc3c 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -61,16 +61,20 @@
#include <QScreen>
#include <QStringBuilder>
#include <QUrl>
+#ifndef QT_NO_ACCESSIBILITY
#include <private/qquickaccessibleattached_p.h>
+#endif // QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
if (QQuickWebEngineView *v = qobject_cast<QQuickWebEngineView*>(object))
return new QQuickWebEngineViewAccessible(v);
return 0;
}
+#endif // QT_NO_ACCESSIBILITY
QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
: adapter(new WebContentsAdapter)
@@ -102,7 +106,9 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
// 1x, 2x, 3x etc assets that fit an integral number of pixels.
setDevicePixelRatio(qMax(1, qRound(webPixelRatio)));
}
+#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
+#endif // QT_NO_ACCESSIBILITY
}
QQuickWebEngineViewPrivate::~QQuickWebEngineViewPrivate()
@@ -395,11 +401,13 @@ void QQuickWebEngineViewPrivate::runMediaAccessPermissionRequest(const QUrl &sec
Q_EMIT e->featurePermissionRequested(securityOrigin, feature);
}
+#ifndef QT_NO_ACCESSIBILITY
QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
{
Q_Q(QQuickWebEngineView);
return q;
}
+#endif // QT_NO_ACCESSIBILITY
WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
{
@@ -414,6 +422,7 @@ void QQuickWebEngineViewPrivate::setDevicePixelRatio(qreal devicePixelRatio)
m_dpiScale = devicePixelRatio / screen->devicePixelRatio();
}
+#ifndef QT_NO_ACCESSIBILITY
QQuickWebEngineViewAccessible::QQuickWebEngineViewAccessible(QQuickWebEngineView *o)
: QAccessibleObject(o)
{}
@@ -460,6 +469,7 @@ QAccessible::State QQuickWebEngineViewAccessible::state() const
QAccessible::State s;
return s;
}
+#endif // QT_NO_ACCESSIBILITY
void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContents)
{
@@ -497,8 +507,10 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
this->setActiveFocusOnTab(true);
this->setFlag(QQuickItem::ItemIsFocusScope);
+#ifndef QT_NO_ACCESSIBILITY
QQuickAccessibleAttached *accessible = QQuickAccessibleAttached::qmlAttachedProperties(this);
accessible->setRole(QAccessible::Grouping);
+#endif // QT_NO_ACCESSIBILITY
}
QQuickWebEngineView::~QQuickWebEngineView()
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 22713ee2..f3ceb2c6 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -155,7 +155,9 @@ private:
friend class QQuickWebEngineViewExperimental;
friend class QQuickWebEngineViewExperimentalExtension;
friend class QQuickWebEngineNewViewRequest;
+#ifndef QT_NO_ACCESSIBILITY
friend class QQuickWebEngineViewAccessible;
+#endif // QT_NO_ACCESSIBILITY
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 6662f1f0..3ab95c64 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -175,7 +175,9 @@ public:
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { }
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
+#ifndef QT_NO_ACCESSIBILITY
virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE;
+#endif // QT_NO_ACCESSIBILITY
virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &errorController);
@@ -202,6 +204,7 @@ private:
qreal m_dpiScale;
};
+#ifndef QT_NO_ACCESSIBILITY
class QQuickWebEngineViewAccessible : public QAccessibleObject
{
public:
@@ -217,7 +220,7 @@ public:
private:
QQuickWebEngineView *engineView() const { return static_cast<QQuickWebEngineView*>(object()); }
};
-
+#endif // QT_NO_ACCESSIBILITY
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWebEngineViewExperimental)
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 72b16f28..068c1752 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -39,6 +39,7 @@
#include <QApplication>
#include <QAuthenticator>
#include <QClipboard>
+#include <QContextMenuEvent>
#include <QFileDialog>
#include <QIcon>
#include <QInputDialog>
@@ -342,10 +343,12 @@ void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &security
Q_EMIT q->featurePermissionRequested(securityOrigin, requestedFeature);
}
+#ifndef QT_NO_ACCESSIBILITY
QObject *QWebEnginePagePrivate::accessibilityParentObject()
{
return view;
}
+#endif // QT_NO_ACCESSIBILITY
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 7856b824..9fd81b0c 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -258,7 +258,9 @@ private:
friend class QWebEngineView;
friend class QWebEngineViewPrivate;
+#ifndef QT_NO_ACCESSIBILITY
friend class QWebEngineViewAccessible;
+#endif // QT_NO_ACCESSIBILITY
};
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 54129229..2307e7a9 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -135,7 +135,9 @@ public:
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) Q_DECL_OVERRIDE;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
+#ifndef QT_NO_ACCESSIBILITY
virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE;
+#endif // QT_NO_ACCESSIBILITY
virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
virtual void allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE;
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 8d219899..63ac4057 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -85,19 +85,22 @@ void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page)
}
}
-
+#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
if (QWebEngineView *v = qobject_cast<QWebEngineView*>(object))
return new QWebEngineViewAccessible(v);
return Q_NULLPTR;
}
+#endif // QT_NO_ACCESSIBILITY
QWebEngineViewPrivate::QWebEngineViewPrivate()
: page(0)
, m_pendingContextMenuEvent(false)
{
+#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
+#endif // QT_NO_ACCESSIBILITY
}
QWebEngineView::QWebEngineView(QWidget *parent)
@@ -274,6 +277,7 @@ void QWebEngineView::contextMenuEvent(QContextMenuEvent *event)
menu->popup(event->globalPos());
}
+#ifndef QT_NO_ACCESSIBILITY
int QWebEngineViewAccessible::childCount() const
{
if (view() && child(0))
@@ -294,6 +298,7 @@ int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
return 0;
return -1;
}
+#endif // QT_NO_ACCESSIBILITY
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index 9db971f7..e0cc3f4e 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -59,6 +59,7 @@ public:
bool m_pendingContextMenuEvent;
};
+#ifndef QT_NO_ACCESSIBILITY
class QWebEngineViewAccessible : public QAccessibleWidget
{
public:
@@ -72,7 +73,7 @@ public:
private:
QWebEngineView *view() const { return static_cast<QWebEngineView*>(object()); }
};
-
+#endif // QT_NO_ACCESSIBILITY
QT_END_NAMESPACE
diff --git a/tests/quicktestbrowser/quicktestbrowser.pro b/tests/quicktestbrowser/quicktestbrowser.pro
index ac8fe74b..51ea5a28 100644
--- a/tests/quicktestbrowser/quicktestbrowser.pro
+++ b/tests/quicktestbrowser/quicktestbrowser.pro
@@ -1,3 +1,5 @@
+requires(contains(QT_CONFIG, accessibility))
+
TEMPLATE = app
TARGET = quicktestbrowser