summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/WebViewImpl.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-06-25 13:35:59 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-25 13:35:59 +0200
commit79ad030d505ccf79cf10aa9f8189ca3e2f61f6f4 (patch)
tree0287b1a69d84492c901e8bc820e635e7133809a0 /Source/WebKit/chromium/src/WebViewImpl.cpp
parent682ab87480e7757346802ce7f54cfdbdfeb2339e (diff)
downloadqtwebkit-79ad030d505ccf79cf10aa9f8189ca3e2f61f6f4.tar.gz
Imported WebKit commit c4b613825abd39ac739a47d7b4410468fcef66dc (http://svn.webkit.org/repository/webkit/trunk@121147)
New snapshot that includes Win32 debug build fix (use SVGAllInOne)
Diffstat (limited to 'Source/WebKit/chromium/src/WebViewImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index 67b7c041e..d2393c31c 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -1351,10 +1351,28 @@ void WebViewImpl::resize(const WebSize& newSize)
{
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 @@ void WebViewImpl::resize(const WebSize& newSize)
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();
}
@@ -2086,6 +2131,19 @@ bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti
return true;
}
+bool WebViewImpl::setEditableSelectionOffsets(int start, int end)
+{
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return false;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return false;
+
+ return editor->setSelectionOffsets(start, end);
+}
+
bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length)
{
const Frame* focused = focusedWebCoreFrame();
@@ -2341,6 +2399,11 @@ void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
frame->view()->scrollElementToRect(elementNode, IntRect(rect.x, rect.y, rect.width, rect.height));
}
+void WebViewImpl::advanceFocus(bool reverse)
+{
+ page()->focusController()->advanceFocus(reverse ? FocusDirectionBackward : FocusDirectionForward, 0);
+}
+
double WebViewImpl::zoomLevel()
{
return m_zoomLevel;
@@ -3479,6 +3542,8 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
setDeviceScaleFactor(m_deviceScaleInCompositor);
}
+ bool visible = page()->visibilityState() == PageVisibilityStateVisible;
+ m_layerTreeView.setVisible(visible);
m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
if (m_compositorSurfaceReady)
m_layerTreeView.setSurfaceReady();