targetRect.inflateX(s_widthMargin);
FloatRect viewportRect(FloatPoint(), m_viewImpl->page()->viewSize());
float targetScale = pageClientImpl->adjustScaleWithViewport(viewportRect.width() / targetRect.width());
-
- FloatRect newContentsRect(targetRect.center(), FloatSize(viewportRect.width() / targetScale, viewportRect.height() / targetScale));
- if (targetRect.height() > newContentsRect.height())
- newContentsRect.setY(target.y());
+ FloatRect newContentsRect;
+
+ // Scale to 2.0 if target scale factor is same as current scale factor.
+ // If width of area is same as width of contents and contents is fitted to the viewport now,
+ // the current scale factor and target scale factor can be same.
+ if (fabs(pageClientImpl->scaleFactor() - targetScale) < numeric_limits<float>::epsilon()) {
+ targetScale = 2;
+ newContentsRect = FloatRect(target, FloatSize(viewportRect.width() / targetScale, viewportRect.height() / targetScale));
+ } else {
+ newContentsRect = FloatRect(targetRect.center(), FloatSize(viewportRect.width() / targetScale, viewportRect.height() / targetScale));
+ if (targetRect.height() > newContentsRect.height())
+ newContentsRect.setY(target.y());
+ }
newContentsRect.move(-newContentsRect.width() / 2, -newContentsRect.height() / 2);
newContentsRect.setLocation(pageClientImpl->boundContentsPositionAtScale(newContentsRect.location(), targetScale));
bool SmartZoom::isWorking()
{
return m_scaleAnimator ? true : false;
-}
\ No newline at end of file
+}