Title: [120877] trunk/Source/WebKit/chromium
- Revision
- 120877
- Author
- [email protected]
- Date
- 2012-06-20 15:57:58 -0700 (Wed, 20 Jun 2012)
Log Message
[chromium] Support mobile device rotation resizing
https://bugs.webkit.org/show_bug.cgi?id=86819
Patch by Alexandre Elias <[email protected]> on 2012-06-20
Reviewed by Adam Barth.
Resizes on a mobile device are caused either by rotation or
on-screen-keyboard bringup, and need different treatment to remain
naturally laid out, scaled and scrolled without disorienting the user.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::resize):
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (120876 => 120877)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-20 22:49:13 UTC (rev 120876)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-20 22:57:58 UTC (rev 120877)
@@ -1,3 +1,17 @@
+2012-06-20 Alexandre Elias <[email protected]>
+
+ [chromium] Support mobile device rotation resizing
+ https://bugs.webkit.org/show_bug.cgi?id=86819
+
+ Reviewed by Adam Barth.
+
+ Resizes on a mobile device are caused either by rotation or
+ on-screen-keyboard bringup, and need different treatment to remain
+ naturally laid out, scaled and scrolled without disorienting the user.
+
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::resize):
+
2012-06-19 James Robinson <[email protected]>
[chromium] Separate LayerRenderer initialization from updateLayers
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (120876 => 120877)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-06-20 22:49:13 UTC (rev 120876)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-06-20 22:57:58 UTC (rev 120877)
@@ -1351,10 +1351,28 @@
{
if (m_shouldAutoResize || m_size == newSize)
return;
+
+ FrameView* view = mainFrameImpl()->frameView();
+ if (!view)
+ return;
+
+ WebSize oldSize = m_size;
+ float oldPageScaleFactor = pageScaleFactor();
+ IntSize oldScrollOffset = view->scrollOffset();
+ int oldFixedLayoutWidth = fixedLayoutSize().width;
+
m_size = newSize;
#if ENABLE(VIEWPORT)
if (settings()->viewportEnabled()) {
+ // Fallback width is used to layout sites designed for desktop. The
+ // conventional size used by all mobile browsers is 980. When a mobile
+ // device has a particularly wide screen (such as a 10" tablet held in
+ // landscape), it can be larger.
+ const int standardFallbackWidth = 980;
+ int dpiIndependentViewportWidth = newSize.width / page()->deviceScaleFactor();
+ settings()->setLayoutFallbackWidth(std::max(standardFallbackWidth, dpiIndependentViewportWidth));
+
ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()->viewportArguments();
m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArguments);
}
@@ -1369,6 +1387,33 @@
webFrame->frameView()->resize(newSize.width, newSize.height);
}
+#if ENABLE(VIEWPORT)
+ if (settings()->viewportEnabled()) {
+ // Relayout immediately to obtain the new content width, which is needed
+ // to calculate the minimum scale limit.
+ view->layout();
+ computePageScaleFactorLimits();
+ // When the device rotates:
+ // - If the page width is unchanged, then zoom by new width/old width
+ // such as to keep the same content horizontally onscreen.
+ // - If the page width stretches proportionally to the change in
+ // screen width, then don't zoom at all (assuming the content has
+ // scaled uniformly, then the same content will be horizontally
+ // onscreen).
+ // - If the page width partially stretches, then zoom partially to
+ // make up the difference.
+ // In all cases try to keep the same content at the top of the screen.
+ float viewportWidthRatio = !oldSize.width ? 1 : newSize.width / (float) oldSize.width;
+ float fixedLayoutWidthRatio = !oldFixedLayoutWidth ? 1 : fixedLayoutSize().width / (float) oldFixedLayoutWidth;
+ float scaleMultiplier = viewportWidthRatio / fixedLayoutWidthRatio;
+ if (scaleMultiplier != 1) {
+ IntSize scrollOffsetAtNewScale = oldScrollOffset;
+ scrollOffsetAtNewScale.scale(scaleMultiplier);
+ setPageScaleFactor(oldPageScaleFactor * scaleMultiplier, IntPoint(scrollOffsetAtNewScale));
+ }
+ }
+#endif
+
sendResizeEventAndRepaint();
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes