Make page scale shrink FrameView in applyPageScaleInCompositor mode
https://bugs.webkit.org/show_bug.cgi?id=107424

Reviewed by Levi Weintraub.

If applyPageScaleFactorInCompositor is enabled (Chromium-only setting),
instead of the entire document expanding as the user pinch zooms, the
viewport shrinks instead. This patch applies the pageScaleFactor to
visibleContentRect to get this behavior, and simplifies Chromium's
resize logic to stop hiding the true viewport size from WebCore.

I verified that the scaling makes sense for all the callers of
visibleContentRect. The exceptions are clip-layer size,
layout size in non-fixed-layout mode, and text autosizing, which need
the original unscaled size. Therefore I added a new method
unscaledVisibleContentSize() to ScrollView/FrameView.

This patch also modifies Page::setPageScaleFactor to perform no
invalidates or layout when applyPageScaleFactorInCompositor is true,
and also writes pageScaleFactor into HistoryItems instead of using
frameScaleFactor.

Since all behavior changes are tied to applyPageScaleFactorInCompositor,
this patch should be a no-op for non-Chromium ports.

Source/Platform:

* chromium/public/WebLayerTreeView.h:
(WebLayerTreeView):
(WebKit::WebLayerTreeView::adjustEventPointForPinchZoom):

Source/WebCore:

New unit tests in WebFrameTest.cpp.

* loader/HistoryController.cpp:
(WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
Use pageScaleFactor here because frameScaleFactor always returns 1
with our setting.
* page/FrameView.cpp:
(WebCore::FrameView::visibleContentScaleFactor):
(WebCore):
* page/FrameView.h:
(FrameView):
* page/Page.cpp:
(WebCore::Page::setPageScaleFactor): Make setPageScaleFactor stop
invalidating/layouting as this is handled by our compositor.
* platform/ScrollView.cpp:
(WebCore::ScrollView::unscaledVisibleContentSize): This new method
just returns the original visible rect without pageScaleFactor being
applied.
(WebCore):
(WebCore::ScrollView::visibleContentRect): This now is divided by
pageScaleFactor if our setting is active.
(WebCore::ScrollView::layoutSize):
* platform/ScrollView.h:
(WebCore::ScrollView::visibleContentScaleFactor): Returns
pageScaleFactor if the visible rect is scaled, 1 normally.
(ScrollView):
(WebCore::ScrollView::layoutWidth):
(WebCore::ScrollView::layoutHeight):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateRootLayerPosition): Clip layer
should use unscaled size, because it's above the root scroll layer
on the layer tree (i.e. page scale isn't applied on it).
* rendering/TextAutosizer.cpp:
(WebCore::TextAutosizer::processSubtree): Text autosizer should use
unscaled size, because it cares about physical screen size.

Source/WebKit/chromium:

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::scaledSize): Returns the post page-scale size
similar to what visibleContentRect() now returns, except that it may
be at a different scale than the current one.
(WebKit::WebViewImpl::size): Back to returning density-independent
size without any tricks, not the "layoutSize()" fake viewport.
(WebKit::WebViewImpl::resize):
(WebKit::WebViewImpl::handleInputEvent): No need to apply
implTransform anymore as WebKit knows the true scroll offset; just
divide event coords by pageScaleFactor.
(WebKit::WebViewImpl::clampOffsetAtScale): Make this method support
applyPageScaleFactorInCompositor.  This is used to pre-clamp scroll
offsets at a given viewport size.
(WebKit::WebViewImpl::setPageScaleFactorPreservingScrollOffset): Make
this method support applyPageScaleFactorInCompositor (don't scale
scroll offsets as they are now scale-independent).
(WebKit::WebViewImpl::setPageScaleFactor): Make this method always use
clampOffsetAtScale instead of bypassing it, since it's now supported.
Also notify the compositor to update its state.
(WebKit::WebViewImpl::contentsSize): Convenience method, removed
difference between scaled and unscaled.
(WebKit::WebViewImpl::layoutSize): This method returned the "fake"
size we used to give FrameView.  Now no longer used for much.
(WebKit::WebViewImpl::computePageScaleFactorLimits):
(WebKit::WebViewImpl::didChangeContentsSize): Remove unnecessary
resize() now that we can give the true size to FrameView.
(WebKit::WebViewImpl::updateLayerTreeViewport): Use layoutSize()
directly now that FrameView no longer uses it.
* src/WebViewImpl.h:
(WebViewImpl):
* tests/WebFrameTest.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141053 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp
index 8a69769..0472791 100644
--- a/Source/WebCore/platform/ScrollView.cpp
+++ b/Source/WebCore/platform/ScrollView.cpp
@@ -225,14 +225,13 @@
     delegatesScrollingDidChange();
 }
 
-#if !PLATFORM(GTK)
-IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
+IntSize ScrollView::unscaledVisibleContentSize(bool includeScrollbars) const
 {
     if (platformWidget())
-        return platformVisibleContentRect(includeScrollbars);
+        return platformVisibleContentRect(includeScrollbars).size();
 
     if (!m_fixedVisibleContentRect.isEmpty())
-        return m_fixedVisibleContentRect;
+        return m_fixedVisibleContentRect.size();
 
     int verticalScrollbarWidth = 0;
     int horizontalScrollbarHeight = 0;
@@ -244,26 +243,28 @@
             horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0;
     }
 
-    return IntRect(m_scrollOffset.width(),
-                   m_scrollOffset.height(),
-                   max(0, width() - verticalScrollbarWidth), 
+    return IntSize(max(0, width() - verticalScrollbarWidth),
                    max(0, height() - horizontalScrollbarHeight));
 }
+
+#if !PLATFORM(GTK)
+IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
+{
+    if (platformWidget())
+        return platformVisibleContentRect(includeScrollbars);
+
+    if (!m_fixedVisibleContentRect.isEmpty())
+        return m_fixedVisibleContentRect;
+
+    FloatSize visibleContentSize = unscaledVisibleContentSize(includeScrollbars);
+    visibleContentSize.scale(1 / visibleContentScaleFactor());
+    return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize));
+}
 #endif
 
 IntSize ScrollView::layoutSize() const
 {
-    return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? visibleSize() : m_fixedLayoutSize;
-}
-
-int ScrollView::layoutWidth() const
-{
-    return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? visibleWidth() : m_fixedLayoutSize.width();
-}
-
-int ScrollView::layoutHeight() const
-{
-    return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? visibleHeight() : m_fixedLayoutSize.height();
+    return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledVisibleContentSize(false) : m_fixedLayoutSize;
 }
 
 IntSize ScrollView::fixedLayoutSize() const