2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #include "qtouchwebpageproxy.h"
25 #include <NativeWebTouchEvent.h>
26 #include <WebEventFactoryQt.h>
28 using namespace WebCore;
30 QTouchWebPageProxy::QTouchWebPageProxy(TouchViewInterface* viewInterface, ViewportInteractionEngine* viewportInteractionEngine)
31 : QtWebPageProxy(viewInterface, 0)
32 , m_panGestureRecognizer(viewportInteractionEngine)
33 , m_pinchGestureRecognizer(viewportInteractionEngine)
38 PassOwnPtr<DrawingAreaProxy> QTouchWebPageProxy::createDrawingAreaProxy()
40 return TiledDrawingAreaProxy::create(touchViewInterface(), m_webPageProxy.get());
43 void QTouchWebPageProxy::processDidCrash()
45 QtWebPageProxy::processDidCrash();
46 m_panGestureRecognizer.reset();
47 m_pinchGestureRecognizer.reset();
50 void QTouchWebPageProxy::paintContent(QPainter* painter, const QRect& area)
52 m_webPageProxy->drawingArea()->paint(IntRect(area), painter);
55 #if ENABLE(TOUCH_EVENTS)
56 void QTouchWebPageProxy::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
58 if (wasEventHandled) {
59 m_panGestureRecognizer.reset();
60 m_pinchGestureRecognizer.reset();
62 m_panGestureRecognizer.recognize(event.nativeEvent());
63 m_pinchGestureRecognizer.recognize(event.nativeEvent());
68 bool QTouchWebPageProxy::handleEvent(QEvent* ev)
71 case QEvent::TouchBegin:
72 case QEvent::TouchEnd:
73 case QEvent::TouchUpdate:
74 touchEvent(static_cast<QTouchEvent*>(ev));
77 return QtWebPageProxy::handleEvent(ev);
80 void QTouchWebPageProxy::setVisibleContentRectAndScale(const QRectF& visibleContentRect, float scale)
82 QRect alignedVisibleContentRect = visibleContentRect.toAlignedRect();
83 drawingArea()->setVisibleContentRectAndScale(alignedVisibleContentRect, scale);
85 // FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
86 m_webPageProxy->setFixedVisibleContentRect(alignedVisibleContentRect);
89 void QTouchWebPageProxy::setVisibleContentRectTrajectoryVector(const QPointF& trajectoryVector)
91 drawingArea()->setVisibleContentRectTrajectoryVector(trajectoryVector);
94 void QTouchWebPageProxy::setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize)
96 m_webPageProxy->setResizesToContentsUsingLayoutSize(targetLayoutSize);
99 void QTouchWebPageProxy::touchEvent(QTouchEvent* event)
101 #if ENABLE(TOUCH_EVENTS)
102 m_webPageProxy->handleTouchEvent(NativeWebTouchEvent(event));
105 ASSERT_NOT_REACHED();
110 void QTouchWebPageProxy::findZoomableAreaForPoint(const QPoint& point)
112 m_webPageProxy->findZoomableAreaForPoint(point);
115 void QTouchWebPageProxy::renderNextFrame()
117 drawingArea()->renderNextFrame();