diff options
author | Christian Strømme <christian.stromme@theqtcompany.com> | 2016-04-04 19:49:28 +0200 |
---|---|---|
committer | Christian Stromme <christian.stromme@theqtcompany.com> | 2016-04-15 13:33:46 +0000 |
commit | dd99ce27b73923823dc19a4a3273cd8bce5193e3 (patch) | |
tree | babcd0fa9a3016b140cb061056e344b3bb14cfa5 /src | |
parent | 299883956859a3eea1f2637a781adfec45c4b3c8 (diff) |
Android: Don't call setClipBounds on the WebView
When High DPI mode is enabled, with a scale different then 1, the values
we get are not in the same scale as setClipBounds expects. While it is
possible to convert the values to native pixel first, it's probably
better if we just disable this functionality on Android, that is, until
a better cross-platform solution can be found.
Task-number: QTBUG-51198
Change-Id: Ia3e3e3911b9ba24d83e49afa6bec61696b93073a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/webview/qwebview_android.cpp | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/src/webview/qwebview_android.cpp b/src/webview/qwebview_android.cpp index f5837bc..7050173 100644 --- a/src/webview/qwebview_android.cpp +++ b/src/webview/qwebview_android.cpp @@ -47,38 +47,9 @@ #include <QtCore/qjsonobject.h> #include <QtCore/qurl.h> #include <QtCore/qdebug.h> -#include <QtCore/qrunnable.h> QT_BEGIN_NAMESPACE -class SetClipBoundsRunnable : public QRunnable -{ -public: - SetClipBoundsRunnable(const QJNIObjectPrivate &view, const QRect &cr) : m_view(view), m_cr(cr) { } - void run() - { - QJNIObjectPrivate cr("android/graphics/Rect", "(IIII)V", 0, 0, m_cr.width(), m_cr.height()); - m_view.callMethod<void>("setClipBounds", "(Landroid/graphics/Rect;)V", cr.object()); - } -private: - QJNIObjectPrivate m_view; - const QRect m_cr; -}; - -static inline bool setClipRect(const QJNIObjectPrivate &view, const QRect &clipRect) -{ - if (QtAndroidPrivate::androidSdkVersion() < 18) - return false; - - if (!view.isValid()) - return false; - - SetClipBoundsRunnable *r = new SetClipBoundsRunnable(view, clipRect); - QtAndroidPrivate::runOnUiThread(r, QJNIEnvironmentPrivate()); - - return true; -} - QWebViewPrivate *QWebViewPrivate::create(QWebView *q) { return new QAndroidWebViewPrivate(q); @@ -207,22 +178,8 @@ void QAndroidWebViewPrivate::setGeometry(const QRect &geometry) QRect newGeometry = geometry; const QWindow *parent = m_window->parent(); - if (parent != 0) { + if (parent != 0) newGeometry.moveTo(parent->mapToGlobal(geometry.topLeft())); - const QRect parentGlobalRect(parent->mapToGlobal(QPoint(0, 0)), parent->geometry().size()); - const QRect clipRect = parentGlobalRect & newGeometry; - if (clipRect != newGeometry) { - const bool clipIsSet = setClipRect(m_webView, clipRect); - const bool topLeftChanged = newGeometry.topLeft() != clipRect.topLeft(); - if (topLeftChanged && clipIsSet) - newGeometry.moveTo(clipRect.topLeft()); - - // If setting the clip rect fails, e.g., if the API level is lower then 18, then we'll - // cheat by simply re-sizing the view. - if (!clipIsSet) - newGeometry = clipRect; - } - } m_window->setGeometry(newGeometry); } |