Modified: trunk/Source/WebKit2/ChangeLog (101484 => 101485)
--- trunk/Source/WebKit2/ChangeLog 2011-11-30 12:05:54 UTC (rev 101484)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-30 12:09:43 UTC (rev 101485)
@@ -1,3 +1,20 @@
+2011-11-30 Kenneth Rohde Christiansen <[email protected]>
+
+ Rename WebKit::ViewportUpdateGuard to *Deferrer and add some better
+ comments to explain its purpose.
+
+ Reviewed by Simon Hausmann.
+
+ * UIProcess/qt/QtViewportInteractionEngine.cpp:
+ (WebKit::ViewportUpdateDeferrer::ViewportUpdateDeferrer):
+ (WebKit::ViewportUpdateDeferrer::~ViewportUpdateDeferrer):
+ (WebKit::QtViewportInteractionEngine::setItemRectVisible):
+ (WebKit::QtViewportInteractionEngine::scaleAnimationStateChanged):
+ (WebKit::QtViewportInteractionEngine::scrollStateChanged):
+ (WebKit::QtViewportInteractionEngine::applyConstraints):
+ (WebKit::QtViewportInteractionEngine::pinchGestureStarted):
+ * UIProcess/qt/QtViewportInteractionEngine.h:
+
2011-11-30 Simon Hausmann <[email protected]>
Build fix. The removal of the Qt threading back-end also removed
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (101484 => 101485)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-30 12:05:54 UTC (rev 101484)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-30 12:09:43 UTC (rev 101485)
@@ -34,26 +34,42 @@
static const int kScaleAnimationDurationMillis = 250;
-// Updating content properties cause the notify signals to be sent by the content item itself.
-// We manage these differently, as we do not want to act on them when we are the ones changing the content.
+// UPDATE DEFERRING (SUSPEND/RESUME)
+// =================================
//
-// When multiple guards are alive, their lifetime must be perfectly imbricated (e.g. if used ouside stack
-// frames). We rely on the first one to trigger the update at the end.
+// When interaction with the content, either by animating or by the hand of the user,
+// it is important to ensure smooth animations of at least 60fps in order to give a
+// good user experience.
//
-// Our public QtViewportInteractionEngine methods should use the guard if they update content in any situation.
+// In order to do this we need to get rid of unknown factors. These include device
+// sensors (geolocation, orientation updates etc), CSS3 animations, _javascript_
+// exectution, sub resource loads etc. We do this by emitting suspend and resume
+// signals, which are then handled by the viewport and propagates to the right place.
+//
+// For this reason the ViewportUpdateDeferrer guard must be used when we interact
+// or animate the content.
+//
+// It should be noted that when we update content properties, we might receive notify
+// signals send my the content item itself, and care should be taken to not act on
+// these unconditionally. An example of this is the pinch zoom, which changes the
+// position and will thus result in a QQuickWebPage::geometryChanged() signal getting
+// emitted.
+//
+// If something should only be executed during update deferring, it is possible to
+// check for that using ASSERT(m_suspendCount).
-class ViewportUpdateGuard {
+class ViewportUpdateDeferrer {
public:
- ViewportUpdateGuard(QtViewportInteractionEngine* engine)
+ ViewportUpdateDeferrer(QtViewportInteractionEngine* engine)
: engine(engine)
{
if (engine->m_suspendCount++)
return;
- engine->contentSuspendRequested();
+ emit engine->contentSuspendRequested();
}
- ~ViewportUpdateGuard()
+ ~ViewportUpdateDeferrer()
{
if (--(engine->m_suspendCount))
return;
@@ -137,7 +153,7 @@
void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect)
{
- ViewportUpdateGuard guard(this);
+ ViewportUpdateDeferrer guard(this);
qreal itemScale = m_viewport->width() / itemRect.width();
@@ -167,7 +183,7 @@
{
switch (newState) {
case QAbstractAnimation::Running:
- m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateGuard(this));
+ m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
break;
case QAbstractAnimation::Stopped:
m_scaleUpdateDeferrer.clear();
@@ -189,7 +205,7 @@
case QScroller::Scrolling:
if (m_scrollUpdateDeferrer)
break;
- m_scrollUpdateDeferrer = adoptPtr(new ViewportUpdateGuard(this));
+ m_scrollUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
break;
default:
break;
@@ -371,7 +387,7 @@
// We always have to apply the constrains even if they didn't change, as
// the initial scale might need to be applied.
- ViewportUpdateGuard guard(this);
+ ViewportUpdateDeferrer guard(this);
m_constraints = constraints;
@@ -452,7 +468,7 @@
m_hadUserInteraction = true;
- m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateGuard(this));
+ m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
m_lastPinchCenterInViewportCoordinates = m_viewport->mapFromItem(m_content, pinchCenterInContentCoordinates);
m_pinchStartScale = m_content->scale();
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (101484 => 101485)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-30 12:05:54 UTC (rev 101484)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-30 12:09:43 UTC (rev 101485)
@@ -38,7 +38,7 @@
namespace WebKit {
-class ViewportUpdateGuard;
+class ViewportUpdateDeferrer;
class QtViewportInteractionEngine : public QObject {
Q_OBJECT
@@ -108,6 +108,8 @@
void scaleAnimationValueChanged(QVariant value) { setItemRectVisible(value.toRectF()); }
private:
+ friend class ViewportUpdateDeferrer;
+
qreal cssScaleFromItem(qreal);
qreal itemScaleFromCSS(qreal);
qreal innerBoundedCSSScale(qreal);
@@ -121,15 +123,15 @@
// As long as the object exists this function will always return the same QScroller instance.
QScroller* scroller() { return QScroller::scroller(this); }
- friend class ViewportUpdateGuard;
const QQuickItem* const m_viewport;
QQuickItem* const m_content;
Constraints m_constraints;
+
int m_suspendCount;
- OwnPtr<ViewportUpdateGuard> m_scaleUpdateDeferrer;
- OwnPtr<ViewportUpdateGuard> m_scrollUpdateDeferrer;
+ OwnPtr<ViewportUpdateDeferrer> m_scaleUpdateDeferrer;
+ OwnPtr<ViewportUpdateDeferrer> m_scrollUpdateDeferrer;
bool m_hadUserInteraction;