Diff
Modified: trunk/Source/WebKit2/ChangeLog (118757 => 118758)
--- trunk/Source/WebKit2/ChangeLog 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/ChangeLog 2012-05-29 12:09:58 UTC (rev 118758)
@@ -1,3 +1,77 @@
+2012-05-29 Kenneth Rohde Christiansen <kenn...@webkit.org>
+
+ [Qt][WK2] Fix failing qmltests::FitToView::test_basic()
+ https://bugs.webkit.org/show_bug.cgi?id=87236
+
+ Reviewed by Simon Hausmann.
+
+ The fix is a combination of things. First of all some events
+ were emitted at the wrong times or when nothing had changed.
+
+ We also initialized the view saying it was suspended which is
+ not correct.
+
+ Another bug was that the touch tap, didn't result in marking
+ the view as having user interaction. This was recently fixed
+ in r118493.
+
+ * UIProcess/API/qt/qquickwebpage.cpp:
+ (QQuickWebPage::setContentsScale):
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate):
+
+ Make sure pageIsSuspended is initialized to false.
+
+ (QQuickWebViewFlickablePrivate::_q_onInformVisibleContentChange):
+
+ Early bail out if there is no change.
+
+ Inform contentScaleCommitted if the scale changed since last time.
+
+ (QQuickWebViewFlickablePrivate::didChangeContentsSize):
+
+ Make sure to commit the right signals, ie. *Changed and not *Committed.
+
+ * UIProcess/API/qt/qquickwebview_p.h:
+ * UIProcess/API/qt/qwebkittest.cpp:
+ (touchPoint):
+ (QWebKitTest::sendTouchEvent):
+ (QWebKitTest::touchTap):
+ (QWebKitTest::touchDoubleTap):
+
+ Add proper touch emulation for the testing system. Call directly
+ to our WebKit API (avoid Qt event loop) to ensure all events gets
+ delivered.
+
+ * UIProcess/API/qt/qwebkittest_p.h:
+ * UIProcess/qt/QtViewportInteractionEngine.cpp:
+ (WebKit::QtViewportInteractionEngine::setItemRectVisible):
+
+ Assert that a ViewportUpdateDeferrer is always used when calling
+ this method.
+
+ (WebKit::QtViewportInteractionEngine::animateItemRectVisible):
+
+ Remove work around now we have the proper fix in place.
+
+ (WebKit::QtViewportInteractionEngine::pagePositionRequest):
+
+ Do not send the informVisibleContentChange manually, use the
+ ViewportUpdateDeferrer instead.
+
+ (WebKit::QtViewportInteractionEngine::cancelScrollAnimation):
+
+ Add missing ViewportUpdateDeferrer.
+
+ (WebKit::QtViewportInteractionEngine::pinchGestureStarted):
+
+ No reason to emit informVisibleContentChange before pinch
+ start, as it is always done on end (due to the ViewportUpdateDeferrer).
+
+ (WebKit::QtViewportInteractionEngine::itemSizeChanged):
+
+ Add missing ViewportUpdateDeferrer.
+
2012-05-29 Caio Marcelo de Oliveira Filho <caio.olive...@openbossa.org>
[Qt] [WK2] Allow user to inject JS scripts when the page loads
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp 2012-05-29 12:09:58 UTC (rev 118758)
@@ -124,7 +124,7 @@
ASSERT(scale > 0);
d->contentsScale = scale;
d->updateSize();
- emit d->viewportItem->experimental()->test()->contentsScaleCommitted();
+ emit d->viewportItem->experimental()->test()->contentsScaleChanged();
}
qreal QQuickWebPage::contentsScale() const
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-05-29 12:09:58 UTC (rev 118758)
@@ -831,7 +831,8 @@
QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* viewport)
: QQuickWebViewPrivate(viewport)
- , pageIsSuspended(true)
+ , pageIsSuspended(false)
+ , lastCommittedScale(-1)
{
// Disable mouse events on the flickable web view so we do not
// select text during pan gestures on platforms which send both
@@ -925,14 +926,19 @@
if (!drawingArea)
return;
- const QRect visibleRect(visibleContentsRect());
+ QRectF accurateVisibleRect(q->boundingRect());
+ accurateVisibleRect.translate(contentPos());
+
+ if (accurateVisibleRect == drawingArea->contentsRect())
+ return;
+
float scale = pageView->contentsScale();
- emit q->experimental()->test()->contentsScaleChanged();
+ if (scale != lastCommittedScale)
+ emit q->experimental()->test()->contentsScaleCommitted();
+ lastCommittedScale = scale;
- QRectF accurateVisibleRect(q->boundingRect());
- accurateVisibleRect.translate(contentPos());
- drawingArea->setVisibleContentsRect(visibleRect, scale, trajectoryVector, FloatPoint(accurateVisibleRect.x(), accurateVisibleRect.y()));
+ drawingArea->setVisibleContentsRect(QRect(visibleContentsRect()), scale, trajectoryVector, FloatPoint(accurateVisibleRect.x(), accurateVisibleRect.y()));
// Ensure that updatePaintNode is always called before painting.
pageView->update();
@@ -969,26 +975,22 @@
float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(attributes, viewportSize, newSize);
- bool scaleCommitNotified = false;
-
if (!qFuzzyCompare(minimumScale, attributes.minimumScale)) {
interactionEngine->setCSSScaleBounds(minimumScale, attributes.maximumScale);
emit q->experimental()->test()->viewportChanged();
if (!interactionEngine->hadUserInteraction() && !pageIsSuspended) {
- // Emits contentsScaleCommitted();
- scaleCommitNotified = true;
+ // Emits contentsScaleChanged();
interactionEngine->setCSSScale(minimumScale);
}
}
// Emit for testing purposes, so that it can be verified that
// we didn't do scale adjustment.
- if (!scaleCommitNotified)
- emit q->experimental()->test()->contentsScaleCommitted();
+ interactionEngine->setItemRectVisible(interactionEngine->nearestValidBounds());
+ emit q->experimental()->test()->contentsScaleCommitted();
}
-
/*!
\qmlsignal WebView::onNavigationRequested(WebNavigationRequest request)
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2012-05-29 12:09:58 UTC (rev 118758)
@@ -217,6 +217,7 @@
QScopedPointer<QQuickWebViewPrivate> d_ptr;
QQuickWebViewExperimental* m_experimental;
+ friend class QWebKitTest;
friend class WebKit::QtViewportInteractionEngine;
friend class WebKit::QtWebPageLoadClient;
friend class WebKit::QtWebPagePolicyClient;
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2012-05-29 12:09:58 UTC (rev 118758)
@@ -242,6 +242,7 @@
private:
QScopedPointer<WebKit::QtViewportInteractionEngine> interactionEngine;
bool pageIsSuspended;
+ float lastCommittedScale;
};
#endif // qquickwebview_p_p_h
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp 2012-05-29 12:09:58 UTC (rev 118758)
@@ -22,9 +22,10 @@
#include "qwebkittest_p.h"
#include "QtViewportInteractionEngine.h"
-#include "QtWebPageEventHandler.h"
-#include "qquickwebview_p.h"
#include "qquickwebview_p_p.h"
+#include "qwindowsysteminterface_qpa.h"
+#include <QMutableListIterator>
+#include <QTouchEvent>
using namespace WebKit;
@@ -43,42 +44,72 @@
QPointF localPos(x, y);
QTouchEvent::TouchPoint point;
+ point.setId(1);
point.setLastPos(localPos);
QRectF touchRect(0, 0, 40, 40);
touchRect.moveCenter(localPos);
point.setRect(touchRect);
+ point.setPressure(1);
return point;
}
+bool QWebKitTest::sendTouchEvent(QQuickWebView* window, QEvent::Type type, const QList<QTouchEvent::TouchPoint>& points, ulong timestamp)
+{
+ ASSERT(window);
+
+ static QTouchDevice* device = 0;
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+
+ Qt::TouchPointStates touchPointStates = 0;
+ foreach (const QTouchEvent::TouchPoint& touchPoint, points)
+ touchPointStates |= touchPoint.state();
+
+ QTouchEvent event(type, device, Qt::NoModifier, touchPointStates, points);
+ event.setTimestamp(timestamp);
+ event.setAccepted(false);
+
+ window->touchEvent(&event);
+
+ return event.isAccepted();
+}
+
bool QWebKitTest::touchTap(QObject* item, qreal x, qreal y, int delay)
{
- if (!qobject_cast<QQuickWebView*>(item)) {
- // FIXME: We only support the actual web view for now.
- qWarning("Touch event \"DoubleTap\" not accepted by receiving item");
+ QQuickWebView* window = qobject_cast<QQuickWebView*>(item);
+
+ if (!window) {
+ qWarning("Touch event \"TouchBegin\" not accepted by receiving item");
return false;
}
// FIXME: implement delay using QTest::qWait() or similar.
Q_UNUSED(delay);
- m_webViewPrivate->pageView->eventHandler()->handleSingleTapEvent(touchPoint(x, y));
+ QList<QTouchEvent::TouchPoint> points;
+ points.append(touchPoint(x, y));
+
+ points[0].setState(Qt::TouchPointPressed);
+ sendTouchEvent(window, QEvent::TouchBegin, points, QDateTime::currentMSecsSinceEpoch());
+
+ points[0].setState(Qt::TouchPointReleased);
+ sendTouchEvent(window, QEvent::TouchEnd, points, QDateTime::currentMSecsSinceEpoch());
+
return true;
}
bool QWebKitTest::touchDoubleTap(QObject* item, qreal x, qreal y, int delay)
{
- if (!qobject_cast<QQuickWebView*>(item)) {
- // FIXME: We only support the actual web view for now.
- qWarning("Touch event \"DoubleTap\" not accepted by receiving item");
+ if (!touchTap(item, x, y, delay))
return false;
- }
- // FIXME: implement delay using QTest::qWait() or similar.
- Q_UNUSED(delay);
+ if (!touchTap(item, x, y, delay))
+ return false;
- m_webViewPrivate->pageView->eventHandler()->handleDoubleTapEvent(touchPoint(x, y));
-
return true;
}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h 2012-05-29 12:09:58 UTC (rev 118758)
@@ -22,6 +22,7 @@
#define qwebkittest_p_h
#include "qwebkitglobal.h"
+#include "qquickwebview_p.h"
#include <QtCore/QObject>
#include <QtCore/QPointer>
@@ -60,6 +61,8 @@
QWebKitTest(QQuickWebViewPrivate* webviewPrivate, QObject* parent = 0);
virtual ~QWebKitTest();
+ bool sendTouchEvent(QQuickWebView* window, QEvent::Type type, const QList<QTouchEvent::TouchPoint>& points, ulong timestamp);
+
QSize contentsSize() const;
QVariant contentsScale() const;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (118757 => 118758)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2012-05-29 11:43:28 UTC (rev 118757)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2012-05-29 12:09:58 UTC (rev 118758)
@@ -170,6 +170,9 @@
void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect)
{
+ ASSERT_WITH_MESSAGE(m_suspendCount,
+ "setItemRectVisible has to be guarded using a ViewportUpdateDeferrer.");
+
if (itemRect.isEmpty())
return;
@@ -202,13 +205,6 @@
if (itemRect == currentItemRectVisible)
return;
- // FIXME: Investigate why that animation doesn't run when we are unfocused.
- if (!m_viewport->isVisible() || !m_viewport->hasFocus()) {
- // Apply the end result immediately when we are non-visible.
- setItemRectVisible(itemRect);
- return;
- }
-
QEasingCurve easingCurve;
easingCurve.setCustomType(physicalOvershoot);
@@ -286,10 +282,8 @@
QRectF endVisibleContentRect(endPosition / endItemScale, m_viewport->boundingRect().size() / endItemScale);
+ ViewportUpdateDeferrer(this);
setItemRectVisible(endVisibleContentRect);
-
- // Make sure that tiles all around the viewport will be requested.
- emit informVisibleContentChange(QPointF());
}
void QtViewportInteractionEngine::touchBegin()
@@ -553,6 +547,7 @@
// immediately positioned back to valid boundaries.
m_viewport->cancelFlick();
+ ViewportUpdateDeferrer(this);
setItemRectVisible(nearestValidBounds());
}
@@ -582,9 +577,6 @@
m_lastPinchCenterInViewportCoordinates = pinchCenterInViewportCoordinates;
m_pinchStartScale = m_content->contentsScale();
-
- // Reset the tiling look-ahead vector so that tiles all around the viewport will be requested on pinch-end.
- emit informVisibleContentChange(QPointF());
}
void QtViewportInteractionEngine::pinchGestureRequestUpdate(const QPointF& pinchCenterInViewportCoordinates, qreal totalScaleFactor)
@@ -639,6 +631,7 @@
if (m_suspendCount)
return;
+ ViewportUpdateDeferrer(this);
setItemRectVisible(nearestValidBounds());
}