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
[Shadow] Gesture event is not fired in ShadowDOM
https://bugs.webkit.org/show_bug.cgi?id=107797

Reviewed by Dimitri Glazkov.

Source/WebCore:

Gesture event (e.g. touchstart) is not fired in ShadowDOM.

We have to run event retargetting algorithm to retarget touchTarget, however it is not implemented yet (Bug 107800).
Until it's implemented, we use the shadow ancestor node of touchTarget in Document treescope as touchTarget
for backward compatibility. If a touch event is fired in nested ShadowDOM, touchTarget will be always element in
document tree, so an event listener in ShadowDOM will get a wrong touchTarget. However we prioritized
the correctness of document tree.

Test: fast/dom/shadow/touch-event.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleTouchEvent): Allows us to take elements in ShadowDOM.

LayoutTests:

* fast/dom/shadow/touch-event-expected.txt: Added.
* fast/dom/shadow/touch-event.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141054 268f45cc-cd09-0410-ab3c-d52691b4dbfc