Modified: trunk/Source/WebKit2/ChangeLog (101338 => 101339)
--- trunk/Source/WebKit2/ChangeLog 2011-11-29 08:53:11 UTC (rev 101338)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-29 09:15:49 UTC (rev 101339)
@@ -1,3 +1,23 @@
+2011-11-29 Kenneth Rohde Christiansen <[email protected]>
+
+ [Qt] QQuickWebView gets wrong position after reload
+ https://bugs.webkit.org/show_bug.cgi?id=73292
+
+ Reviewed by Simon Hausmann.
+
+ The ensureContentWithinViewportBoundary animates the current viewport
+ item into boundaries. That of course breaks when we try to animate it,
+ given the initial-scale which hasn't been applied; so apply it.
+
+ Also put the QScroller settings code in the ctor as it never changes.
+
+ * UIProcess/qt/QtViewportInteractionEngine.cpp:
+ (WebKit::QtViewportInteractionEngine::QtViewportInteractionEngine):
+ (WebKit::QtViewportInteractionEngine::ensureContentWithinViewportBoundary):
+ (WebKit::QtViewportInteractionEngine::reset):
+ (WebKit::QtViewportInteractionEngine::applyConstraints):
+ * UIProcess/qt/QtViewportInteractionEngine.h:
+
2011-11-29 Roland Steiner <[email protected]>
<style scoped>: add ENABLE(STYLE_SCOPED) flag to WebKit
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (101338 => 101339)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-29 08:53:11 UTC (rev 101338)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-29 09:15:49 UTC (rev 101339)
@@ -102,6 +102,22 @@
{
reset();
+ QScrollerProperties properties = scroller()->scrollerProperties();
+
+ // The QtPanGestureRecognizer is responsible for recognizing the gesture
+ // thus we need to disable the drag start distance.
+ properties.setScrollMetric(QScrollerProperties::DragStartDistance, 0.0);
+
+ // Set some default QScroller constrains to mimic the physics engine of the N9 browser.
+ properties.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
+ properties.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
+ properties.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
+ properties.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.635);
+ properties.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
+ properties.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
+
+ scroller()->setScrollerProperties(properties);
+
connect(m_content, SIGNAL(widthChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
connect(m_content, SIGNAL(heightChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
@@ -308,21 +324,17 @@
animateItemRectVisible(endVisibleContentRect);
}
-void QtViewportInteractionEngine::ensureContentWithinViewportBoundary()
+void QtViewportInteractionEngine::ensureContentWithinViewportBoundary(bool immediate)
{
if (scrollAnimationActive() || scaleAnimationActive())
return;
qreal currentCSSScale = cssScaleFromItem(m_content->scale());
- bool userHasScaledContent = m_userInteractionFlags & UserHasScaledContent;
- if (!userHasScaledContent)
- currentCSSScale = m_constraints.initialScale;
-
qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(currentCSSScale));
const QRectF viewportRect = m_viewport->boundingRect();
- const QPointF viewportHotspot = viewportRect.center();
+ QPointF viewportHotspot = viewportRect.center();
QPointF endPosition = m_content->mapFromItem(m_viewport, viewportHotspot) * endItemScale - viewportHotspot;
@@ -331,7 +343,7 @@
QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
- if (!userHasScaledContent)
+ if (immediate)
setItemRectVisible(endVisibleContentRect);
else
animateItemRectVisible(endVisibleContentRect);
@@ -340,26 +352,11 @@
void QtViewportInteractionEngine::reset()
{
ViewportUpdateGuard guard(this);
+
m_userInteractionFlags = UserHasNotInteractedWithContent;
scroller()->stop();
m_scaleAnimation->stop();
-
- QScrollerProperties properties = scroller()->scrollerProperties();
-
- // The QtPanGestureRecognizer is responsible for recognizing the gesture
- // thus we need to disable the drag start distance.
- properties.setScrollMetric(QScrollerProperties::DragStartDistance, 0.0);
-
- // Set some default QScroller constrains to mimic the physics engine of the N9 browser.
- properties.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
- properties.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
- properties.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
- properties.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.635);
- properties.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
- properties.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
-
- scroller()->setScrollerProperties(properties);
}
void QtViewportInteractionEngine::applyConstraints(const Constraints& constraints)
@@ -370,7 +367,15 @@
ViewportUpdateGuard guard(this);
m_constraints = constraints;
- ensureContentWithinViewportBoundary();
+ bool userHasScaledContent = m_userInteractionFlags & UserHasScaledContent;
+ if (!userHasScaledContent) {
+ qreal initialScale = innerBoundedCSSScale(m_constraints.initialScale);
+ m_content->setScale(itemScaleFromCSS(initialScale));
+ }
+
+ // If the web app changes successively changes the viewport on purpose
+ // it wants to be in control and we should disable animations.
+ ensureContentWithinViewportBoundary(/* immediate */ true);
}
bool QtViewportInteractionEngine::scrollAnimationActive() const
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (101338 => 101339)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-29 08:53:11 UTC (rev 101338)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-29 09:15:49 UTC (rev 101339)
@@ -111,7 +111,7 @@
qreal outerBoundedCSSScale(qreal);
QRectF computePosRangeForItemAtScale(qreal itemScale) const;
- void ensureContentWithinViewportBoundary();
+ void ensureContentWithinViewportBoundary(bool immediate = false);
void scaleContent(const QPointF& centerInContentCoordinates, qreal scale);