- // setVisibleContentRect() is called to adjust visible content rect after device rotation
- // In below cases, it shouldn't be called
- // 1. page is not rendered yet
- // 2. viewport attributes are changed by WebCore's empty document(progress == 0.1)
- // 3. there's no input field zoom(device rotation without IME)
- if (m_pageDidRendered && m_viewImpl->page()->estimatedProgress() > 0.1 && !ewk_view_focused_node_adjust(m_viewImpl->view())) {
- IntSize contentsSize = m_viewImpl->page()->contentsSize();
- double minimumScaleByContentWidth = max(((double)viewSize().width() / contentsSize.width()), 0.25);
- float newScale = scaleFactor();
-
- // If contents width exceeds viewport layout width and content is userScalable, update minimumScale.
- if (m_viewportConstraints.userScalable)
- m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
-
- // If zoom was fitted to width before the rotation, newScale should be fitted to width again.
- if (fabs(scaleFactor() - prevMinimumScale) < numeric_limits<double>::epsilon())
+
+ // if content is reloaded, contents size will not be changed
+ // so, we need to calculate minimum scale here.
+ // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
+ if (m_viewportConstraints.userScalable)
+ m_viewportConstraints.minimumScale = availableMinimumScale();
+
+ // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
+ if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
+ return;
+
+ // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
+ if (ewk_view_focused_node_adjust(m_viewImpl->view()))
+ return;
+
+ float newScale = scaleFactor();
+ Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
+ int angle = ecore_evas_rotation_get(ee);
+ bool isRotated = (angle != m_viewportAngle);
+
+ // if it's rotated, we need to fit content to viewport by minimize the scale
+ if (isRotated) {
+ m_viewportAngle = angle;
+ if (m_viewportFitsToContent)