mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove pinch viewports.
Sky doesn't have concept of pinch zoom. Remove more frame-level scrolling machinery. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/681583002
This commit is contained in:
parent
7c001a4ffa
commit
57a45f79ff
@ -741,8 +741,6 @@ sky_core_files = [
|
||||
"frame/LocalFrame.h",
|
||||
"frame/Location.cpp",
|
||||
"frame/Location.h",
|
||||
"frame/PinchViewport.cpp",
|
||||
"frame/PinchViewport.h",
|
||||
"frame/PlatformEventController.cpp",
|
||||
"frame/PlatformEventController.h",
|
||||
"frame/PlatformEventDispatcher.cpp",
|
||||
|
||||
@ -99,9 +99,7 @@ void ViewportDescription::reportMobilePageStats(const LocalFrame* mainFrame) con
|
||||
// To get an idea of how "far" the viewport is from the device's ideal width, we
|
||||
// report the zoom level that we'd need to be at for the entire page to be visible.
|
||||
int viewportWidth = maxWidth.intValue();
|
||||
int windowWidth = mainFrame->document()->settings()->pinchVirtualViewportEnabled()
|
||||
? mainFrame->host()->pinchViewport().size().width()
|
||||
: mainFrame->view()->frameRect().width();
|
||||
int windowWidth = mainFrame->view()->frameRect().width();
|
||||
int overviewZoomPercent = 100 * windowWidth / static_cast<float>(viewportWidth);
|
||||
Platform::current()->histogramSparse("Viewport.OverviewZoom", overviewZoomPercent);
|
||||
}
|
||||
|
||||
@ -45,7 +45,6 @@ PassOwnPtrWillBeRawPtr<FrameHost> FrameHost::create(Page& page)
|
||||
|
||||
FrameHost::FrameHost(Page& page)
|
||||
: m_page(&page)
|
||||
, m_pinchViewport(adoptPtr(new PinchViewport(*this)))
|
||||
, m_eventHandlerRegistry(adoptPtrWillBeNoop(new EventHandlerRegistry(*this)))
|
||||
{
|
||||
}
|
||||
@ -75,11 +74,6 @@ float FrameHost::deviceScaleFactor() const
|
||||
return m_page->deviceScaleFactor();
|
||||
}
|
||||
|
||||
PinchViewport& FrameHost::pinchViewport() const
|
||||
{
|
||||
return *m_pinchViewport;
|
||||
}
|
||||
|
||||
EventHandlerRegistry& FrameHost::eventHandlerRegistry() const
|
||||
{
|
||||
return *m_eventHandlerRegistry;
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
#ifndef FrameHost_h
|
||||
#define FrameHost_h
|
||||
|
||||
#include "core/frame/PinchViewport.h"
|
||||
#include "platform/heap/Handle.h"
|
||||
#include "wtf/FastAllocBase.h"
|
||||
#include "wtf/Noncopyable.h"
|
||||
@ -43,7 +42,6 @@ namespace blink {
|
||||
class Chrome;
|
||||
class EventHandlerRegistry;
|
||||
class Page;
|
||||
class PinchViewport;
|
||||
class Settings;
|
||||
class UseCounter;
|
||||
class Visitor;
|
||||
@ -74,7 +72,6 @@ public:
|
||||
// This value does not account for Page zoom, use LocalFrame::devicePixelRatio instead.
|
||||
float deviceScaleFactor() const;
|
||||
|
||||
PinchViewport& pinchViewport() const;
|
||||
EventHandlerRegistry& eventHandlerRegistry() const;
|
||||
|
||||
void trace(Visitor*);
|
||||
@ -83,7 +80,6 @@ private:
|
||||
explicit FrameHost(Page&);
|
||||
|
||||
RawPtrWillBeMember<Page> m_page;
|
||||
const OwnPtr<PinchViewport> m_pinchViewport;
|
||||
const OwnPtrWillBeMember<EventHandlerRegistry> m_eventHandlerRegistry;
|
||||
};
|
||||
|
||||
|
||||
@ -207,10 +207,6 @@ void FrameView::setFrameRect(const IntRect& newRect)
|
||||
}
|
||||
|
||||
viewportConstrainedVisibleContentSizeChanged(newRect.width() != oldRect.width(), newRect.height() != oldRect.height());
|
||||
|
||||
if (oldRect.size() != newRect.size()
|
||||
&& m_frame->settings()->pinchVirtualViewportEnabled())
|
||||
page()->frameHost().pinchViewport().mainFrameDidChangeSize();
|
||||
}
|
||||
|
||||
Page* FrameView::page() const
|
||||
@ -759,36 +755,7 @@ LayoutRect FrameView::viewportConstrainedVisibleContentRect() const
|
||||
|
||||
void FrameView::viewportConstrainedVisibleContentSizeChanged(bool widthChanged, bool heightChanged)
|
||||
{
|
||||
if (!hasViewportConstrainedObjects())
|
||||
return;
|
||||
|
||||
// If viewport is not enabled, frameRect change will cause layout size change and then layout.
|
||||
// Otherwise, viewport constrained objects need their layout flags set separately to ensure
|
||||
// they are positioned correctly. In the virtual-viewport pinch mode frame rect changes wont
|
||||
// necessarily cause a layout size change so only take this early-out if we're in old-style
|
||||
// pinch.
|
||||
if (m_frame->settings()
|
||||
&& !m_frame->settings()->viewportEnabled()
|
||||
&& !m_frame->settings()->pinchVirtualViewportEnabled())
|
||||
return;
|
||||
|
||||
ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
|
||||
for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
|
||||
RenderObject* renderer = *it;
|
||||
RenderStyle* style = renderer->style();
|
||||
if (widthChanged) {
|
||||
if (style->width().isFixed() && (style->left().isAuto() || style->right().isAuto()))
|
||||
renderer->setNeedsPositionedMovementLayout();
|
||||
else
|
||||
renderer->setNeedsLayoutAndFullPaintInvalidation();
|
||||
}
|
||||
if (heightChanged) {
|
||||
if (style->height().isFixed() && (style->top().isAuto() || style->bottom().isAuto()))
|
||||
renderer->setNeedsPositionedMovementLayout();
|
||||
else
|
||||
renderer->setNeedsLayoutAndFullPaintInvalidation();
|
||||
}
|
||||
}
|
||||
// FIXME(sky): Remove
|
||||
}
|
||||
|
||||
IntSize FrameView::scrollOffsetForFixedPosition() const
|
||||
@ -886,38 +853,6 @@ void FrameView::restoreScrollbar()
|
||||
// FIXME(sky): Remove
|
||||
}
|
||||
|
||||
void FrameView::scrollElementToRect(Element* element, const IntRect& rect)
|
||||
{
|
||||
// FIXME(http://crbug.com/371896) - This method shouldn't be manually doing
|
||||
// coordinate transformations to the PinchViewport.
|
||||
IntRect targetRect(rect);
|
||||
|
||||
m_frame->document()->updateLayoutIgnorePendingStylesheets();
|
||||
|
||||
bool pinchVirtualViewportEnabled = m_frame->settings()->pinchVirtualViewportEnabled();
|
||||
|
||||
if (pinchVirtualViewportEnabled) {
|
||||
PinchViewport& pinchViewport = m_frame->page()->frameHost().pinchViewport();
|
||||
|
||||
IntSize pinchViewportSize = expandedIntSize(pinchViewport.visibleRect().size());
|
||||
targetRect.moveBy(ceiledIntPoint(pinchViewport.visibleRect().location()));
|
||||
targetRect.setSize(pinchViewportSize.shrunkTo(targetRect.size()));
|
||||
}
|
||||
|
||||
LayoutRect bounds = element->boundingBox();
|
||||
int centeringOffsetX = (targetRect.width() - bounds.width()) / 2;
|
||||
int centeringOffsetY = (targetRect.height() - bounds.height()) / 2;
|
||||
|
||||
IntPoint targetOffset(
|
||||
bounds.x() - centeringOffsetX - targetRect.x(),
|
||||
bounds.y() - centeringOffsetY - targetRect.y());
|
||||
|
||||
if (pinchVirtualViewportEnabled) {
|
||||
IntPoint remainder = IntPoint(targetOffset - scrollPosition());
|
||||
m_frame->page()->frameHost().pinchViewport().move(remainder);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(sky): remove
|
||||
IntSize FrameView::layoutSize(IncludeScrollbarsInRect) const
|
||||
{
|
||||
@ -1365,9 +1300,7 @@ IntSize FrameView::inputEventsOffsetForEmulation() const
|
||||
|
||||
float FrameView::inputEventsScaleFactor() const
|
||||
{
|
||||
float pageScale = m_frame->settings()->pinchVirtualViewportEnabled()
|
||||
? m_frame->page()->frameHost().pinchViewport().scale()
|
||||
: visibleContentScaleFactor();
|
||||
float pageScale = visibleContentScaleFactor();
|
||||
return pageScale * m_inputEventsScaleFactorForEmulation;
|
||||
}
|
||||
|
||||
|
||||
@ -188,7 +188,6 @@ public:
|
||||
|
||||
void forceLayout(bool allowSubtree = false);
|
||||
|
||||
void scrollElementToRect(Element*, const IntRect&);
|
||||
void scrollContentsIfNeededRecursive();
|
||||
|
||||
// Methods to convert points and rects between the coordinate space of the renderer, and this view.
|
||||
|
||||
@ -1,432 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "core/frame/PinchViewport.h"
|
||||
|
||||
#include "core/frame/FrameHost.h"
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/frame/Settings.h"
|
||||
#include "core/page/Chrome.h"
|
||||
#include "core/page/ChromeClient.h"
|
||||
#include "core/page/Page.h"
|
||||
#include "core/page/scrolling/ScrollingCoordinator.h"
|
||||
#include "core/rendering/RenderView.h"
|
||||
#include "core/rendering/compositing/RenderLayerCompositor.h"
|
||||
#include "platform/TraceEvent.h"
|
||||
#include "platform/geometry/FloatSize.h"
|
||||
#include "platform/graphics/GraphicsLayer.h"
|
||||
#include "platform/graphics/GraphicsLayerFactory.h"
|
||||
#include "platform/scroll/Scrollbar.h"
|
||||
#include "public/platform/Platform.h"
|
||||
#include "public/platform/WebCompositorSupport.h"
|
||||
#include "public/platform/WebLayer.h"
|
||||
#include "public/platform/WebLayerTreeView.h"
|
||||
#include "public/platform/WebScrollbar.h"
|
||||
#include "public/platform/WebScrollbarLayer.h"
|
||||
|
||||
using blink::WebLayer;
|
||||
using blink::WebLayerTreeView;
|
||||
using blink::WebScrollbar;
|
||||
using blink::WebScrollbarLayer;
|
||||
using blink::FrameHost;
|
||||
using blink::GraphicsLayer;
|
||||
using blink::GraphicsLayerFactory;
|
||||
|
||||
namespace blink {
|
||||
|
||||
PinchViewport::PinchViewport(FrameHost& owner)
|
||||
: m_frameHost(owner)
|
||||
, m_scale(1)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
PinchViewport::~PinchViewport() { }
|
||||
|
||||
void PinchViewport::setSize(const IntSize& size)
|
||||
{
|
||||
if (m_size == size)
|
||||
return;
|
||||
|
||||
TRACE_EVENT2("blink", "PinchViewport::setSize", "width", size.width(), "height", size.height());
|
||||
m_size = size;
|
||||
|
||||
// Make sure we clamp the offset to within the new bounds.
|
||||
setLocation(m_offset);
|
||||
|
||||
if (m_innerViewportContainerLayer) {
|
||||
m_innerViewportContainerLayer->setSize(m_size);
|
||||
|
||||
// Need to re-compute sizes for the overlay scrollbars.
|
||||
setupScrollbar(WebScrollbar::Horizontal);
|
||||
setupScrollbar(WebScrollbar::Vertical);
|
||||
}
|
||||
}
|
||||
|
||||
void PinchViewport::reset()
|
||||
{
|
||||
setLocation(FloatPoint());
|
||||
setScale(1);
|
||||
}
|
||||
|
||||
void PinchViewport::mainFrameDidChangeSize()
|
||||
{
|
||||
TRACE_EVENT0("blink", "PinchViewport::mainFrameDidChangeSize");
|
||||
|
||||
// In unit tests we may not have initialized the layer tree.
|
||||
if (m_innerViewportScrollLayer)
|
||||
m_innerViewportScrollLayer->setSize(contentsSize());
|
||||
|
||||
// Make sure the viewport's offset is clamped within the newly sized main frame.
|
||||
setLocation(m_offset);
|
||||
}
|
||||
|
||||
FloatRect PinchViewport::visibleRect() const
|
||||
{
|
||||
FloatSize scaledSize(m_size);
|
||||
scaledSize.scale(1 / m_scale);
|
||||
return FloatRect(m_offset, scaledSize);
|
||||
}
|
||||
|
||||
FloatRect PinchViewport::visibleRectInDocument() const
|
||||
{
|
||||
if (!mainFrame() || !mainFrame()->view())
|
||||
return FloatRect();
|
||||
|
||||
FloatRect viewRect = mainFrame()->view()->visibleContentRect();
|
||||
FloatRect pinchRect = visibleRect();
|
||||
pinchRect.moveBy(viewRect.location());
|
||||
return pinchRect;
|
||||
}
|
||||
|
||||
void PinchViewport::scrollIntoView(const FloatRect& rect)
|
||||
{
|
||||
// FIXME(sky): Delete this whole file.
|
||||
}
|
||||
|
||||
void PinchViewport::setLocation(const FloatPoint& newLocation)
|
||||
{
|
||||
FloatPoint clampedOffset(clampOffsetToBoundaries(newLocation));
|
||||
|
||||
if (clampedOffset == m_offset)
|
||||
return;
|
||||
|
||||
m_offset = clampedOffset;
|
||||
|
||||
ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator();
|
||||
ASSERT(coordinator);
|
||||
coordinator->scrollableAreaScrollLayerDidChange(this);
|
||||
}
|
||||
|
||||
void PinchViewport::move(const FloatPoint& delta)
|
||||
{
|
||||
setLocation(m_offset + delta);
|
||||
}
|
||||
|
||||
void PinchViewport::setScale(float scale)
|
||||
{
|
||||
if (scale == m_scale)
|
||||
return;
|
||||
|
||||
m_scale = scale;
|
||||
|
||||
// Old-style pinch sets scale here but we shouldn't call into the
|
||||
// clamping code below.
|
||||
if (!m_innerViewportScrollLayer)
|
||||
return;
|
||||
|
||||
// Ensure we clamp so we remain within the bounds.
|
||||
setLocation(visibleRect().location());
|
||||
|
||||
// TODO: We should probably be calling scaleDidChange type functions here.
|
||||
// see Page::setPageScaleFactor.
|
||||
}
|
||||
|
||||
// Modifies the top of the graphics layer tree to add layers needed to support
|
||||
// the inner/outer viewport fixed-position model for pinch zoom. When finished,
|
||||
// the tree will look like this (with * denoting added layers):
|
||||
//
|
||||
// *rootTransformLayer
|
||||
// +- *innerViewportContainerLayer (fixed pos container)
|
||||
// +- *pageScaleLayer
|
||||
// | +- *innerViewportScrollLayer
|
||||
// | +-- overflowControlsHostLayer (root layer)
|
||||
// | +-- outerViewportContainerLayer (fixed pos container) [frame container layer in RenderLayerCompositor]
|
||||
// | | +-- outerViewportScrollLayer [frame scroll layer in RenderLayerCompositor]
|
||||
// | | +-- content layers ...
|
||||
// | +-- horizontal ScrollbarLayer (non-overlay)
|
||||
// | +-- verticalScrollbarLayer (non-overlay)
|
||||
// | +-- scroll corner (non-overlay)
|
||||
// +- *horizontalScrollbarLayer (overlay)
|
||||
// +- *verticalScrollbarLayer (overlay)
|
||||
//
|
||||
void PinchViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, GraphicsLayerFactory* graphicsLayerFactory)
|
||||
{
|
||||
TRACE_EVENT1("blink", "PinchViewport::attachToLayerTree", "currentLayerTreeRoot", (bool)currentLayerTreeRoot);
|
||||
if (!currentLayerTreeRoot) {
|
||||
m_innerViewportScrollLayer->removeAllChildren();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLayerTreeRoot->parent() && currentLayerTreeRoot->parent() == m_innerViewportScrollLayer)
|
||||
return;
|
||||
|
||||
if (!m_innerViewportScrollLayer) {
|
||||
ASSERT(!m_overlayScrollbarHorizontal
|
||||
&& !m_overlayScrollbarVertical
|
||||
&& !m_pageScaleLayer
|
||||
&& !m_innerViewportContainerLayer);
|
||||
|
||||
// FIXME: The root transform layer should only be created on demand.
|
||||
m_rootTransformLayer = GraphicsLayer::create(graphicsLayerFactory, this);
|
||||
m_innerViewportContainerLayer = GraphicsLayer::create(graphicsLayerFactory, this);
|
||||
m_pageScaleLayer = GraphicsLayer::create(graphicsLayerFactory, this);
|
||||
m_innerViewportScrollLayer = GraphicsLayer::create(graphicsLayerFactory, this);
|
||||
m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactory, this);
|
||||
m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory, this);
|
||||
|
||||
blink::ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator();
|
||||
ASSERT(coordinator);
|
||||
coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportScrollLayer.get(), true);
|
||||
|
||||
// Set masks to bounds so the compositor doesn't clobber a manually
|
||||
// set inner viewport container layer size.
|
||||
m_innerViewportContainerLayer->setMasksToBounds(m_frameHost.settings().mainFrameClipsContent());
|
||||
m_innerViewportContainerLayer->setSize(m_size);
|
||||
|
||||
m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer(
|
||||
m_innerViewportContainerLayer->platformLayer());
|
||||
m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, true);
|
||||
|
||||
m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get());
|
||||
m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get());
|
||||
m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get());
|
||||
m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get());
|
||||
m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get());
|
||||
|
||||
// Ensure this class is set as the scroll layer's ScrollableArea.
|
||||
coordinator->scrollableAreaScrollLayerDidChange(this);
|
||||
|
||||
// Setup the inner viewport overlay scrollbars.
|
||||
setupScrollbar(WebScrollbar::Horizontal);
|
||||
setupScrollbar(WebScrollbar::Vertical);
|
||||
}
|
||||
|
||||
m_innerViewportScrollLayer->removeAllChildren();
|
||||
m_innerViewportScrollLayer->addChild(currentLayerTreeRoot);
|
||||
|
||||
// We only need to disable the existing (outer viewport) scrollbars
|
||||
// if the existing ones are already overlay.
|
||||
// FIXME: If we knew in advance before the overflowControlsHostLayer goes
|
||||
// away, we would re-enable the drawing of these scrollbars.
|
||||
// FIXME: This doesn't seem to work (at least on Android). Commenting out for now until
|
||||
// I figure out how to access RenderLayerCompositor from here.
|
||||
// if (GraphicsLayer* scrollbar = m_frameHost->compositor()->layerForHorizontalScrollbar())
|
||||
// scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollbars());
|
||||
// if (GraphicsLayer* scrollbar = m_frameHost->compositor()->layerForVerticalScrollbar())
|
||||
// scrollbar->setDrawsContent(!page->mainFrame()->view()->hasOverlayScrollbars());
|
||||
}
|
||||
|
||||
void PinchViewport::setupScrollbar(WebScrollbar::Orientation orientation)
|
||||
{
|
||||
bool isHorizontal = orientation == WebScrollbar::Horizontal;
|
||||
GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ?
|
||||
m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get();
|
||||
OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ?
|
||||
m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical;
|
||||
|
||||
const int overlayScrollbarThickness = m_frameHost.settings().pinchOverlayScrollbarThickness();
|
||||
|
||||
if (!webScrollbarLayer) {
|
||||
ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator();
|
||||
ASSERT(coordinator);
|
||||
ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrollbar : VerticalScrollbar;
|
||||
webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreOrientation, overlayScrollbarThickness, 0, false);
|
||||
|
||||
webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformLayer());
|
||||
scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->layer());
|
||||
scrollbarGraphicsLayer->setDrawsContent(false);
|
||||
}
|
||||
|
||||
int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().width() - overlayScrollbarThickness;
|
||||
int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height() - overlayScrollbarThickness : 0;
|
||||
int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - overlayScrollbarThickness : overlayScrollbarThickness;
|
||||
int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportContainerLayer->size().height() - overlayScrollbarThickness;
|
||||
|
||||
// Use the GraphicsLayer to position the scrollbars.
|
||||
scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition));
|
||||
scrollbarGraphicsLayer->setSize(IntSize(width, height));
|
||||
scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height));
|
||||
}
|
||||
|
||||
void PinchViewport::registerLayersWithTreeView(WebLayerTreeView* layerTreeView) const
|
||||
{
|
||||
TRACE_EVENT0("blink", "PinchViewport::registerLayersWithTreeView");
|
||||
ASSERT(layerTreeView);
|
||||
ASSERT(m_frameHost.page().mainFrame());
|
||||
ASSERT(m_frameHost.page().mainFrame()->contentRenderer());
|
||||
|
||||
RenderLayerCompositor* compositor = m_frameHost.page().mainFrame()->contentRenderer()->compositor();
|
||||
// Get the outer viewport scroll layer.
|
||||
WebLayer* scrollLayer = compositor->scrollLayer()->platformLayer();
|
||||
|
||||
m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer);
|
||||
m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer);
|
||||
|
||||
ASSERT(compositor);
|
||||
layerTreeView->registerViewportLayers(
|
||||
m_pageScaleLayer->platformLayer(),
|
||||
m_innerViewportScrollLayer->platformLayer(),
|
||||
scrollLayer);
|
||||
}
|
||||
|
||||
void PinchViewport::clearLayersForTreeView(WebLayerTreeView* layerTreeView) const
|
||||
{
|
||||
ASSERT(layerTreeView);
|
||||
|
||||
layerTreeView->clearViewportLayers();
|
||||
}
|
||||
|
||||
int PinchViewport::scrollSize(ScrollbarOrientation orientation) const
|
||||
{
|
||||
IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition();
|
||||
return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scrollDimensions.height();
|
||||
}
|
||||
|
||||
IntPoint PinchViewport::minimumScrollPosition() const
|
||||
{
|
||||
return IntPoint();
|
||||
}
|
||||
|
||||
IntPoint PinchViewport::maximumScrollPosition() const
|
||||
{
|
||||
return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size());
|
||||
}
|
||||
|
||||
IntRect PinchViewport::scrollableAreaBoundingBox() const
|
||||
{
|
||||
// This method should return the bounding box in the parent view's coordinate
|
||||
// space; however, PinchViewport technically isn't a child of any Frames.
|
||||
// Nonetheless, the PinchViewport always occupies the entire main frame so just
|
||||
// return that.
|
||||
LocalFrame* frame = mainFrame();
|
||||
|
||||
if (!frame || !frame->view())
|
||||
return IntRect();
|
||||
|
||||
return frame->view()->frameRect();
|
||||
}
|
||||
|
||||
IntSize PinchViewport::contentsSize() const
|
||||
{
|
||||
LocalFrame* frame = mainFrame();
|
||||
|
||||
if (!frame || !frame->view())
|
||||
return IntSize();
|
||||
|
||||
ASSERT(frame->view()->visibleContentScaleFactor() == 1);
|
||||
return frame->view()->visibleContentRect(IncludeScrollbars).size();
|
||||
}
|
||||
|
||||
void PinchViewport::invalidateScrollbarRect(Scrollbar*, const IntRect&)
|
||||
{
|
||||
// Do nothing. Pinch scrollbars live on the compositor thread and will
|
||||
// be updated when the viewport is synced to the CC.
|
||||
}
|
||||
|
||||
void PinchViewport::setScrollOffset(const IntPoint& offset)
|
||||
{
|
||||
setLocation(offset);
|
||||
}
|
||||
|
||||
GraphicsLayer* PinchViewport::layerForContainer() const
|
||||
{
|
||||
return m_innerViewportContainerLayer.get();
|
||||
}
|
||||
|
||||
GraphicsLayer* PinchViewport::layerForScrolling() const
|
||||
{
|
||||
return m_innerViewportScrollLayer.get();
|
||||
}
|
||||
|
||||
GraphicsLayer* PinchViewport::layerForHorizontalScrollbar() const
|
||||
{
|
||||
return m_overlayScrollbarHorizontal.get();
|
||||
}
|
||||
|
||||
GraphicsLayer* PinchViewport::layerForVerticalScrollbar() const
|
||||
{
|
||||
return m_overlayScrollbarVertical.get();
|
||||
}
|
||||
|
||||
void PinchViewport::notifyAnimationStarted(const GraphicsLayer*, double monotonicTime)
|
||||
{
|
||||
}
|
||||
|
||||
void PinchViewport::paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip)
|
||||
{
|
||||
}
|
||||
|
||||
LocalFrame* PinchViewport::mainFrame() const
|
||||
{
|
||||
return m_frameHost.page().mainFrame();
|
||||
}
|
||||
|
||||
FloatPoint PinchViewport::clampOffsetToBoundaries(const FloatPoint& offset)
|
||||
{
|
||||
FloatPoint clampedOffset(offset);
|
||||
clampedOffset = clampedOffset.shrunkTo(FloatPoint(maximumScrollPosition()));
|
||||
clampedOffset = clampedOffset.expandedTo(FloatPoint(minimumScrollPosition()));
|
||||
return clampedOffset;
|
||||
}
|
||||
|
||||
String PinchViewport::debugName(const GraphicsLayer* graphicsLayer)
|
||||
{
|
||||
String name;
|
||||
if (graphicsLayer == m_innerViewportContainerLayer.get()) {
|
||||
name = "Inner Viewport Container Layer";
|
||||
} else if (graphicsLayer == m_pageScaleLayer.get()) {
|
||||
name = "Page Scale Layer";
|
||||
} else if (graphicsLayer == m_innerViewportScrollLayer.get()) {
|
||||
name = "Inner Viewport Scroll Layer";
|
||||
} else if (graphicsLayer == m_overlayScrollbarHorizontal.get()) {
|
||||
name = "Overlay Scrollbar Horizontal Layer";
|
||||
} else if (graphicsLayer == m_overlayScrollbarVertical.get()) {
|
||||
name = "Overlay Scrollbar Vertical Layer";
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,165 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Google Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef PinchViewport_h
|
||||
#define PinchViewport_h
|
||||
|
||||
#include "platform/geometry/FloatPoint.h"
|
||||
#include "platform/geometry/FloatRect.h"
|
||||
#include "platform/geometry/IntSize.h"
|
||||
#include "platform/graphics/GraphicsLayerClient.h"
|
||||
#include "platform/scroll/ScrollableArea.h"
|
||||
#include "public/platform/WebScrollbar.h"
|
||||
#include "public/platform/WebSize.h"
|
||||
#include "wtf/OwnPtr.h"
|
||||
#include "wtf/PassOwnPtr.h"
|
||||
|
||||
namespace blink {
|
||||
class WebLayerTreeView;
|
||||
class WebScrollbarLayer;
|
||||
}
|
||||
|
||||
namespace blink {
|
||||
|
||||
class FrameHost;
|
||||
class GraphicsContext;
|
||||
class GraphicsLayer;
|
||||
class GraphicsLayerFactory;
|
||||
class IntRect;
|
||||
class IntSize;
|
||||
class LocalFrame;
|
||||
|
||||
// Represents the pinch-to-zoom viewport the user is currently seeing the page through. This
|
||||
// class corresponds to the InnerViewport on the compositor. It is a ScrollableArea; it's
|
||||
// offset is set through the GraphicsLayer <-> CC sync mechanisms. Its contents is the page's
|
||||
// main FrameView, which corresponds to the outer viewport. The inner viewport is always contained
|
||||
// in the outer viewport and can pan within it.
|
||||
class PinchViewport final : public GraphicsLayerClient, public ScrollableArea {
|
||||
public:
|
||||
explicit PinchViewport(FrameHost&);
|
||||
virtual ~PinchViewport();
|
||||
|
||||
void attachToLayerTree(GraphicsLayer*, GraphicsLayerFactory*);
|
||||
GraphicsLayer* rootGraphicsLayer()
|
||||
{
|
||||
return m_rootTransformLayer.get();
|
||||
}
|
||||
GraphicsLayer* containerLayer()
|
||||
{
|
||||
return m_innerViewportContainerLayer.get();
|
||||
}
|
||||
|
||||
// Sets the location of the inner viewport relative to the outer viewport. The
|
||||
// coordinates are in partial CSS pixels.
|
||||
void setLocation(const FloatPoint&);
|
||||
void move(const FloatPoint&);
|
||||
|
||||
// Sets the size of the inner viewport when unscaled in CSS pixels.
|
||||
// This will be clamped to the size of the outer viewport (the main frame).
|
||||
void setSize(const IntSize&);
|
||||
IntSize size() const { return m_size; }
|
||||
|
||||
// Resets the viewport to initial state.
|
||||
void reset();
|
||||
|
||||
// Let the viewport know that the main frame changed size (either through screen
|
||||
// rotation on Android or window resize elsewhere).
|
||||
void mainFrameDidChangeSize();
|
||||
|
||||
void setScale(float);
|
||||
float scale() const { return m_scale; }
|
||||
|
||||
void registerLayersWithTreeView(blink::WebLayerTreeView*) const;
|
||||
void clearLayersForTreeView(blink::WebLayerTreeView*) const;
|
||||
|
||||
// The portion of the unzoomed frame visible in the inner "pinch" viewport,
|
||||
// in partial CSS pixels. Relative to the main frame.
|
||||
FloatRect visibleRect() const;
|
||||
|
||||
// The viewport rect relative to the document origin, in partial CSS pixels.
|
||||
FloatRect visibleRectInDocument() const;
|
||||
|
||||
// Scroll the main frame and pinch viewport so that the given rect in the
|
||||
// top-level document is centered in the viewport. This method will avoid
|
||||
// scrolling the pinch viewport unless necessary.
|
||||
void scrollIntoView(const FloatRect&);
|
||||
private:
|
||||
// ScrollableArea implementation
|
||||
virtual bool isActive() const override { return false; }
|
||||
virtual int scrollSize(ScrollbarOrientation) const override;
|
||||
virtual bool isScrollCornerVisible() const override { return false; }
|
||||
virtual IntRect scrollCornerRect() const override { return IntRect(); }
|
||||
virtual IntPoint scrollPosition() const override { return flooredIntPoint(m_offset); }
|
||||
virtual IntPoint minimumScrollPosition() const override;
|
||||
virtual IntPoint maximumScrollPosition() const override;
|
||||
virtual int visibleHeight() const override { return visibleRect().height(); };
|
||||
virtual int visibleWidth() const override { return visibleRect().width(); };
|
||||
virtual IntSize contentsSize() const override;
|
||||
virtual bool scrollbarsCanBeActive() const override { return false; }
|
||||
virtual IntRect scrollableAreaBoundingBox() const override;
|
||||
virtual bool userInputScrollable(ScrollbarOrientation) const override { return true; }
|
||||
virtual bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
|
||||
virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
|
||||
virtual void invalidateScrollCornerRect(const IntRect&) override { }
|
||||
virtual void setScrollOffset(const IntPoint&) override;
|
||||
virtual GraphicsLayer* layerForContainer() const override;
|
||||
virtual GraphicsLayer* layerForScrolling() const override;
|
||||
virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
|
||||
virtual GraphicsLayer* layerForVerticalScrollbar() const override;
|
||||
|
||||
// GraphicsLayerClient implementation.
|
||||
virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTime) override;
|
||||
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) override;
|
||||
virtual String debugName(const GraphicsLayer*) override;
|
||||
|
||||
void setupScrollbar(blink::WebScrollbar::Orientation);
|
||||
FloatPoint clampOffsetToBoundaries(const FloatPoint&);
|
||||
|
||||
LocalFrame* mainFrame() const;
|
||||
|
||||
FrameHost& m_frameHost;
|
||||
OwnPtr<GraphicsLayer> m_rootTransformLayer;
|
||||
OwnPtr<GraphicsLayer> m_innerViewportContainerLayer;
|
||||
OwnPtr<GraphicsLayer> m_pageScaleLayer;
|
||||
OwnPtr<GraphicsLayer> m_innerViewportScrollLayer;
|
||||
OwnPtr<GraphicsLayer> m_overlayScrollbarHorizontal;
|
||||
OwnPtr<GraphicsLayer> m_overlayScrollbarVertical;
|
||||
OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarHorizontal;
|
||||
OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarVertical;
|
||||
|
||||
// Offset of the pinch viewport from the main frame's origin, in CSS pixels.
|
||||
FloatPoint m_offset;
|
||||
float m_scale;
|
||||
IntSize m_size;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // PinchViewport_h
|
||||
@ -146,15 +146,7 @@ forceZeroLayoutHeight initial=false, invalidate=ViewportDescription
|
||||
# crbug.com/304873 tracks removal once it's been enabled on all platforms.
|
||||
touchEditingEnabled initial=false
|
||||
|
||||
# Settings for experimental desktop pinch-zoom support (with semantics
|
||||
# optimized for large screens). Pinch-zoom generally is implemented mainly
|
||||
# outside of blink (in the compositor) and doesn't require any settings.
|
||||
# These settings are for an experimental modification to how pinch-zoom
|
||||
# behaves. TODO(wjmaclean): link to design document.
|
||||
# crbug.com/304869 tracks removal.
|
||||
pinchVirtualViewportEnabled initial=false
|
||||
useSolidColorScrollbars initial=true
|
||||
pinchOverlayScrollbarThickness type=int, initial=0
|
||||
|
||||
mainFrameClipsContent initial=true
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@
|
||||
#include "core/frame/FrameHost.h"
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/frame/PinchViewport.h"
|
||||
#include "core/html/parser/HTMLDocumentParser.h"
|
||||
#include "core/html/parser/HTMLParserIdioms.h"
|
||||
#include "core/inspector/ConsoleMessage.h"
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
#include "core/frame/FrameHost.h"
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/frame/PinchViewport.h"
|
||||
#include "core/frame/Settings.h"
|
||||
#include "core/html/HTMLElement.h"
|
||||
#include "core/page/AutoscrollController.h"
|
||||
|
||||
@ -152,8 +152,6 @@ public:
|
||||
virtual void setOpenGLMultisamplingEnabled(bool) = 0;
|
||||
virtual void setPerTilePaintingEnabled(bool) = 0;
|
||||
virtual void setPictographFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON) = 0;
|
||||
virtual void setPinchOverlayScrollbarThickness(int) = 0;
|
||||
virtual void setPinchVirtualViewportEnabled(bool) = 0;
|
||||
virtual void setAvailablePointerTypes(int) = 0;
|
||||
virtual void setPrimaryPointerType(PointerType) = 0;
|
||||
virtual void setAvailableHoverTypes(int) = 0;
|
||||
|
||||
@ -196,15 +196,6 @@ public:
|
||||
// virtual viewport pinch.
|
||||
virtual void setMainFrameScrollOffset(const WebPoint& origin) = 0;
|
||||
|
||||
// Sets the offset of the pinch-to-zoom viewport within the main frame, in
|
||||
// partial CSS pixels. The offset will be clamped so the pinch viewport
|
||||
// stays within the frame's bounds.
|
||||
virtual void setPinchViewportOffset(const WebFloatPoint&) = 0;
|
||||
|
||||
// Gets the pinch viewport's current offset within the page's main frame,
|
||||
// in partial CSS pixels.
|
||||
virtual WebFloatPoint pinchViewportOffset() const = 0;
|
||||
|
||||
// Reset any saved values for the scroll and scale state.
|
||||
virtual void resetScrollAndScaleState() = 0;
|
||||
|
||||
|
||||
@ -68,13 +68,6 @@ public:
|
||||
// Called to resize the WebWidget.
|
||||
virtual void resize(const WebSize&) { }
|
||||
|
||||
// Resizes the unscaled pinch viewport. Normally the unscaled pinch
|
||||
// viewport is the same size as the main frame. The passed size becomes the
|
||||
// size of the viewport when unscaled (i.e. scale = 1). This is used to
|
||||
// shrink the visible viewport to allow things like the ChromeOS virtual
|
||||
// keyboard to overlay over content but allow scrolling it into view.
|
||||
virtual void resizePinchViewport(const WebSize&) { }
|
||||
|
||||
// Ends a group of resize events that was started with a call to
|
||||
// willStartLiveResize.
|
||||
virtual void willEndLiveResize() { }
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
#include "core/events/WheelEvent.h"
|
||||
#include "core/frame/FrameHost.h"
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/PinchViewport.h"
|
||||
#include "core/page/Page.h"
|
||||
#include "core/rendering/RenderObject.h"
|
||||
#include "platform/KeyboardCodes.h"
|
||||
@ -73,29 +72,17 @@ static IntSize widgetInputEventsOffset(const Widget* widget)
|
||||
return rootView->inputEventsOffsetForEmulation();
|
||||
}
|
||||
|
||||
static IntPoint pinchViewportOffset(const Widget* widget)
|
||||
{
|
||||
// Event position needs to be adjusted by the pinch viewport's offset within the
|
||||
// main frame before being passed into the widget's convertFromContainingWindow.
|
||||
FrameView* rootView = toFrameView(widget->root());
|
||||
if (!rootView)
|
||||
return IntPoint();
|
||||
|
||||
return flooredIntPoint(rootView->page()->frameHost().pinchViewport().visibleRect().location());
|
||||
}
|
||||
|
||||
// MakePlatformMouseEvent -----------------------------------------------------
|
||||
|
||||
PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e)
|
||||
{
|
||||
float scale = widgetInputEventsScaleFactor(widget);
|
||||
IntSize offset = widgetInputEventsOffset(widget);
|
||||
IntPoint pinchViewport = pinchViewportOffset(widget);
|
||||
|
||||
// FIXME: Widget is always toplevel, unless it's a popup. We may be able
|
||||
// to get rid of this once we abstract popups into a WebKit API.
|
||||
m_position = widget->convertFromContainingWindow(
|
||||
IntPoint((e.x - offset.width()) / scale + pinchViewport.x(), (e.y - offset.height()) / scale + pinchViewport.y()));
|
||||
IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale));
|
||||
m_globalPosition = IntPoint(e.globalX, e.globalY);
|
||||
m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale);
|
||||
m_button = static_cast<MouseButton>(e.button);
|
||||
@ -139,10 +126,9 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
|
||||
{
|
||||
float scale = widgetInputEventsScaleFactor(widget);
|
||||
IntSize offset = widgetInputEventsOffset(widget);
|
||||
IntPoint pinchViewport = pinchViewportOffset(widget);
|
||||
|
||||
m_position = widget->convertFromContainingWindow(
|
||||
IntPoint((e.x - offset.width()) / scale + pinchViewport.x(), (e.y - offset.height()) / scale + pinchViewport.y()));
|
||||
IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale));
|
||||
m_globalPosition = IntPoint(e.globalX, e.globalY);
|
||||
m_deltaX = e.deltaX;
|
||||
m_deltaY = e.deltaY;
|
||||
@ -182,7 +168,6 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
|
||||
{
|
||||
float scale = widgetInputEventsScaleFactor(widget);
|
||||
IntSize offset = widgetInputEventsOffset(widget);
|
||||
IntPoint pinchViewport = pinchViewportOffset(widget);
|
||||
|
||||
switch (e.type) {
|
||||
case WebInputEvent::GestureScrollBegin:
|
||||
@ -261,7 +246,7 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
m_position = widget->convertFromContainingWindow(
|
||||
IntPoint((e.x - offset.width()) / scale + pinchViewport.x(), (e.y - offset.height()) / scale + pinchViewport.y()));
|
||||
IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale));
|
||||
m_globalPosition = IntPoint(e.globalX, e.globalY);
|
||||
m_timestamp = e.timeStampSeconds;
|
||||
|
||||
@ -423,11 +408,9 @@ PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
|
||||
{
|
||||
float scale = 1.0f / widgetInputEventsScaleFactor(widget);
|
||||
IntSize offset = widgetInputEventsOffset(widget);
|
||||
IntPoint pinchViewport = pinchViewportOffset(widget);
|
||||
m_id = point.id;
|
||||
m_state = toPlatformTouchPointState(point.state);
|
||||
FloatPoint pos = (point.position - offset).scaledBy(scale);
|
||||
pos.moveBy(pinchViewport);
|
||||
IntPoint flooredPoint = flooredIntPoint(pos);
|
||||
// This assumes convertFromContainingWindow does only translations, not scales.
|
||||
m_pos = widget->convertFromContainingWindow(flooredPoint) + (pos - flooredPoint);
|
||||
|
||||
@ -667,14 +667,8 @@ void WebLocalFrameImpl::setCaretVisible(bool visible)
|
||||
|
||||
VisiblePosition WebLocalFrameImpl::visiblePositionForWindowPoint(const WebPoint& point)
|
||||
{
|
||||
// FIXME(bokan): crbug.com/371902 - These scale/pinch transforms shouldn't
|
||||
// be ad hoc and explicit.
|
||||
PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
|
||||
FloatPoint unscaledPoint(point);
|
||||
unscaledPoint.moveBy(pinchViewport.visibleRect().location());
|
||||
|
||||
HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping;
|
||||
HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unscaledPoint)));
|
||||
HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(FloatPoint(point))));
|
||||
frame()->document()->renderView()->layer()->hitTest(request, result);
|
||||
|
||||
if (Node* node = result.targetNode())
|
||||
|
||||
@ -514,16 +514,6 @@ void WebSettingsImpl::setSmartInsertDeleteEnabled(bool enabled)
|
||||
m_settings->setSmartInsertDeleteEnabled(enabled);
|
||||
}
|
||||
|
||||
void WebSettingsImpl::setPinchOverlayScrollbarThickness(int thickness)
|
||||
{
|
||||
m_settings->setPinchOverlayScrollbarThickness(thickness);
|
||||
}
|
||||
|
||||
void WebSettingsImpl::setPinchVirtualViewportEnabled(bool enabled)
|
||||
{
|
||||
m_settings->setPinchVirtualViewportEnabled(enabled);
|
||||
}
|
||||
|
||||
void WebSettingsImpl::setUseSolidColorScrollbars(bool enabled)
|
||||
{
|
||||
m_settings->setUseSolidColorScrollbars(enabled);
|
||||
|
||||
@ -106,8 +106,6 @@ public:
|
||||
virtual void setOpenGLMultisamplingEnabled(bool) override;
|
||||
virtual void setPerTilePaintingEnabled(bool) override;
|
||||
virtual void setPictographFontFamily(const WebString&, UScriptCode = USCRIPT_COMMON) override;
|
||||
virtual void setPinchOverlayScrollbarThickness(int) override;
|
||||
virtual void setPinchVirtualViewportEnabled(bool) override;
|
||||
virtual void setAvailablePointerTypes(int) override;
|
||||
virtual void setPrimaryPointerType(PointerType) override;
|
||||
virtual void setAvailableHoverTypes(int) override;
|
||||
|
||||
@ -49,7 +49,6 @@
|
||||
#include "core/frame/FrameHost.h"
|
||||
#include "core/frame/FrameView.h"
|
||||
#include "core/frame/LocalFrame.h"
|
||||
#include "core/frame/PinchViewport.h"
|
||||
#include "core/frame/Settings.h"
|
||||
#include "core/html/HTMLMediaElement.h"
|
||||
#include "core/html/ime/InputMethodContext.h"
|
||||
@ -943,14 +942,6 @@ WebSize WebViewImpl::size()
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void WebViewImpl::resizePinchViewport(const WebSize& newSize)
|
||||
{
|
||||
if (!pinchVirtualViewportEnabled())
|
||||
return;
|
||||
|
||||
page()->frameHost().pinchViewport().setSize(newSize);
|
||||
}
|
||||
|
||||
WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary() const
|
||||
{
|
||||
// FIXME(sky): remove
|
||||
@ -964,11 +955,8 @@ void WebViewImpl::performResize()
|
||||
|
||||
// If the virtual viewport pinch mode is enabled, the main frame will be resized
|
||||
// after layout so it can be sized to the contentsSize.
|
||||
if (!pinchVirtualViewportEnabled() && localFrameRootTemporary()->frameView())
|
||||
if (localFrameRootTemporary()->frameView())
|
||||
localFrameRootTemporary()->frameView()->resize(m_size);
|
||||
|
||||
if (pinchVirtualViewportEnabled())
|
||||
page()->frameHost().pinchViewport().setSize(m_size);
|
||||
}
|
||||
|
||||
void WebViewImpl::resize(const WebSize& newSize)
|
||||
@ -1498,16 +1486,6 @@ bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
|
||||
IntRect scaledAnchor(localFrame->view()->contentsToWindow(anchor));
|
||||
IntRect scaledFocus(localFrame->view()->contentsToWindow(focus));
|
||||
|
||||
if (pinchVirtualViewportEnabled()) {
|
||||
// FIXME(http://crbug.com/371902) - We shouldn't have to do this
|
||||
// manually, the contentsToWindow methods above should be fixed to do
|
||||
// this.
|
||||
IntPoint pinchViewportOffset =
|
||||
roundedIntPoint(page()->frameHost().pinchViewport().visibleRect().location());
|
||||
scaledAnchor.moveBy(-pinchViewportOffset);
|
||||
scaledFocus.moveBy(-pinchViewportOffset);
|
||||
}
|
||||
|
||||
anchor = scaledAnchor;
|
||||
focus = scaledFocus;
|
||||
|
||||
@ -1751,11 +1729,6 @@ void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
|
||||
if (!frame || !frame->view() || !element)
|
||||
return;
|
||||
|
||||
if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) {
|
||||
frame->view()->scrollElementToRect(element, IntRect(rect.x, rect.y, rect.width, rect.height));
|
||||
return;
|
||||
}
|
||||
|
||||
float scale;
|
||||
IntPoint scroll;
|
||||
bool needAnimation;
|
||||
@ -1833,32 +1806,6 @@ IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale)
|
||||
return view->clampOffsetAtScale(offset, scale);
|
||||
}
|
||||
|
||||
bool WebViewImpl::pinchVirtualViewportEnabled() const
|
||||
{
|
||||
ASSERT(page());
|
||||
return page()->settings().pinchVirtualViewportEnabled();
|
||||
}
|
||||
|
||||
void WebViewImpl::setPinchViewportOffset(const WebFloatPoint& offset)
|
||||
{
|
||||
ASSERT(page());
|
||||
|
||||
if (!pinchVirtualViewportEnabled())
|
||||
return;
|
||||
|
||||
page()->frameHost().pinchViewport().setLocation(offset);
|
||||
}
|
||||
|
||||
WebFloatPoint WebViewImpl::pinchViewportOffset() const
|
||||
{
|
||||
ASSERT(page());
|
||||
|
||||
if (!pinchVirtualViewportEnabled())
|
||||
return WebFloatPoint();
|
||||
|
||||
return page()->frameHost().pinchViewport().visibleRect().location();
|
||||
}
|
||||
|
||||
void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin)
|
||||
{
|
||||
updateMainFrameScrollPosition(origin, false);
|
||||
@ -2251,11 +2198,6 @@ void WebViewImpl::setOverlayLayer(GraphicsLayer* layer)
|
||||
if (!m_rootGraphicsLayer)
|
||||
return;
|
||||
|
||||
if (pinchVirtualViewportEnabled()) {
|
||||
m_page->mainFrame()->view()->renderView()->compositor()->setOverlayLayer(layer);
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME(bokan): This path goes away after virtual viewport pinch is enabled everywhere.
|
||||
if (!m_rootTransformLayer)
|
||||
m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compositor()->ensureRootTransformLayer();
|
||||
@ -2305,23 +2247,9 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
|
||||
{
|
||||
suppressInvalidations(true);
|
||||
|
||||
if (pinchVirtualViewportEnabled()) {
|
||||
PinchViewport& pinchViewport = page()->frameHost().pinchViewport();
|
||||
pinchViewport.attachToLayerTree(layer, graphicsLayerFactory());
|
||||
if (layer) {
|
||||
m_rootGraphicsLayer = pinchViewport.rootGraphicsLayer();
|
||||
m_rootLayer = pinchViewport.rootGraphicsLayer()->platformLayer();
|
||||
m_rootTransformLayer = pinchViewport.rootGraphicsLayer();
|
||||
} else {
|
||||
m_rootGraphicsLayer = 0;
|
||||
m_rootLayer = 0;
|
||||
m_rootTransformLayer = 0;
|
||||
}
|
||||
} else {
|
||||
m_rootGraphicsLayer = layer;
|
||||
m_rootLayer = layer ? layer->platformLayer() : 0;
|
||||
m_rootTransformLayer = 0;
|
||||
}
|
||||
m_rootGraphicsLayer = layer;
|
||||
m_rootLayer = layer ? layer->platformLayer() : 0;
|
||||
m_rootTransformLayer = 0;
|
||||
|
||||
setIsAcceleratedCompositingActive(layer != 0);
|
||||
|
||||
@ -2332,20 +2260,13 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
|
||||
m_layerTreeView->setRootLayer(*m_rootLayer);
|
||||
// We register viewport layers here since there may not be a layer
|
||||
// tree view prior to this point.
|
||||
if (pinchVirtualViewportEnabled()) {
|
||||
page()->frameHost().pinchViewport().registerLayersWithTreeView(m_layerTreeView);
|
||||
} else {
|
||||
GraphicsLayer* rootScrollLayer = compositor()->scrollLayer();
|
||||
ASSERT(rootScrollLayer);
|
||||
WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrollLayer->parent()->platformLayer() : 0;
|
||||
m_layerTreeView->registerViewportLayers(pageScaleLayer, rootScrollLayer->platformLayer(), 0);
|
||||
}
|
||||
GraphicsLayer* rootScrollLayer = compositor()->scrollLayer();
|
||||
ASSERT(rootScrollLayer);
|
||||
WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrollLayer->parent()->platformLayer() : 0;
|
||||
m_layerTreeView->registerViewportLayers(pageScaleLayer, rootScrollLayer->platformLayer(), 0);
|
||||
} else {
|
||||
m_layerTreeView->clearRootLayer();
|
||||
if (pinchVirtualViewportEnabled())
|
||||
page()->frameHost().pinchViewport().clearLayersForTreeView(m_layerTreeView);
|
||||
else
|
||||
m_layerTreeView->clearViewportLayers();
|
||||
m_layerTreeView->clearViewportLayers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,6 @@ public:
|
||||
virtual WebSize size() override;
|
||||
virtual void willStartLiveResize() override;
|
||||
virtual void resize(const WebSize&) override;
|
||||
virtual void resizePinchViewport(const WebSize&) override;
|
||||
virtual void willEndLiveResize() override;
|
||||
|
||||
virtual void beginFrame(const WebBeginFrameArgs&) override;
|
||||
@ -150,8 +149,6 @@ public:
|
||||
virtual float setTextZoomFactor(float) override;
|
||||
virtual bool zoomToMultipleTargetsRect(const WebRect&) override;
|
||||
virtual void setMainFrameScrollOffset(const WebPoint&) override;
|
||||
virtual void setPinchViewportOffset(const WebFloatPoint&) override;
|
||||
virtual WebFloatPoint pinchViewportOffset() const override;
|
||||
virtual void resetScrollAndScaleState() override;
|
||||
virtual WebSize contentsPreferredMinimumSize() override;
|
||||
|
||||
@ -327,8 +324,6 @@ public:
|
||||
// Exposed for tests.
|
||||
WebVector<WebCompositionUnderline> compositionUnderlines() const;
|
||||
|
||||
bool pinchVirtualViewportEnabled() const;
|
||||
|
||||
bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_matchesHeuristicsForGpuRasterization; }
|
||||
|
||||
private:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user