Commit e9115cc6 authored by kenneth@webkit.org's avatar kenneth@webkit.org
Browse files

[Qt/WK2] Add initial support for viewport meta tag

https://bugs.webkit.org/show_bug.cgi?id=65975

Reviewed by Benjamin Poulain.

Redirect the viewport arguments through to the view.

* UIProcess/API/qt/qdesktopwebview.cpp:
(QDesktopWebViewPrivate::didReceiveViewportArguments):
* UIProcess/API/qt/qdesktopwebview_p.h:
* UIProcess/API/qt/qtouchwebview.cpp:
(QTouchWebView::geometryChanged):
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::setViewportArguments):
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/qt/TouchViewInterface.cpp:
(WebKit::TouchViewInterface::updateViewportState):
(WebKit::TouchViewInterface::didReceiveViewportArguments):
* UIProcess/qt/TouchViewInterface.h:
(WebKit::TouchViewInterface::ViewportState::ViewportState):
* UIProcess/qt/ViewInterface.h:
* UIProcess/qt/qtouchwebpageproxy.cpp:
(QTouchWebPageProxy::QTouchWebPageProxy):
* UIProcess/qt/qtouchwebpageproxy.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@92851 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6867f044
2011-08-11 Kenneth Rohde Christiansen <kenneth@webkit.org>
[Qt/WK2] Add initial support for viewport meta tag
https://bugs.webkit.org/show_bug.cgi?id=65975
Reviewed by Benjamin Poulain.
Redirect the viewport arguments through to the view.
* UIProcess/API/qt/qdesktopwebview.cpp:
(QDesktopWebViewPrivate::didReceiveViewportArguments):
* UIProcess/API/qt/qdesktopwebview_p.h:
* UIProcess/API/qt/qtouchwebview.cpp:
(QTouchWebView::geometryChanged):
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::setViewportArguments):
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/qt/TouchViewInterface.cpp:
(WebKit::TouchViewInterface::updateViewportState):
(WebKit::TouchViewInterface::didReceiveViewportArguments):
* UIProcess/qt/TouchViewInterface.h:
(WebKit::TouchViewInterface::ViewportState::ViewportState):
* UIProcess/qt/ViewInterface.h:
* UIProcess/qt/qtouchwebpageproxy.cpp:
(QTouchWebPageProxy::QTouchWebPageProxy):
* UIProcess/qt/qtouchwebpageproxy.h:
2011-08-10 David Hyatt <hyatt@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=66004
......
......@@ -89,6 +89,11 @@ void QDesktopWebViewPrivate::startDrag(Qt::DropActions supportedDropActions, con
*clientPosition = widget->mapFromGlobal(*globalPosition);
}
void QDesktopWebViewPrivate::didReceiveViewportArguments(const WebCore::ViewportArguments&)
{
// This feature is only used by QTouchWebView.
}
void QDesktopWebViewPrivate::didFindZoomableArea(const QPoint&, const QRect&)
{
// This feature is only used by QTouchWebView.
......
......@@ -52,6 +52,7 @@ private:
virtual bool isVisible();
virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction);
virtual void didReceiveViewportArguments(const WebCore::ViewportArguments&);
virtual void didFindZoomableArea(const QPoint&, const QRect&);
virtual void didChangeUrl(const QUrl&);
......
......@@ -25,6 +25,8 @@
#include "TouchViewInterface.h"
#include "qtouchwebpage_p.h"
#include "QtWebPageProxy.h"
#include "WebPageGroup.h"
#include "WebPreferences.h"
#include <qgraphicssceneevent.h>
QTouchWebViewPrivate::QTouchWebViewPrivate(QTouchWebView* q)
......@@ -51,6 +53,35 @@ void QTouchWebViewPrivate::viewportRectUpdated()
pageViewPrivate->setViewportRect(viewportRectInPageViewCoordinate);
}
void QTouchWebViewPrivate::updateViewportState()
{
QSize availableSize = q->boundingRect().size().toSize();
WebPageProxy* wkPage = toImpl(page.pageRef());
WebPreferences* wkPrefs = wkPage->pageGroup()->preferences();
WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, wkPrefs->layoutFallbackWidth(), wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
viewport.initialScale = attr.initialScale;
viewport.minimumScale = attr.minimumScale;
viewport.maximumScale = attr.maximumScale;
viewport.pixelRatio = attr.devicePixelRatio;
viewport.isUserScalable = !!attr.userScalable;
// Overwrite minimum scale value with fit-to-view value, unless the the content author
// explicitly says no. NB: We can only do this when we know we have a valid size, ie.
// after initial layout has completed.
// FIXME: Do this on the web process side.
wkPage->setResizesToContentsUsingLayoutSize(attr.layoutSize);
}
void QTouchWebViewPrivate::setViewportArguments(const WebCore::ViewportArguments& args)
{
viewportArguments = args;
updateViewportState();
}
QTouchWebView::QTouchWebView(QSGItem* parent)
: QSGItem(parent)
, d(new QTouchWebViewPrivate(this))
......@@ -71,8 +102,10 @@ QTouchWebPage* QTouchWebView::page()
void QTouchWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
{
QSGItem::geometryChanged(newGeometry, oldGeometry);
if (newGeometry.size() != oldGeometry.size())
if (newGeometry.size() != oldGeometry.size()) {
d->updateViewportState();
d->viewportRectUpdated();
}
}
#include "moc_qtouchwebview.cpp"
......@@ -32,13 +32,35 @@ class QTouchWebViewPrivate
{
public:
QTouchWebViewPrivate(QTouchWebView* q);
void scroll(qreal deltaX, qreal deltaY);
void viewportRectUpdated();
void updateViewportState();
void setViewportArguments(const WebCore::ViewportArguments& args);
struct ViewportState {
ViewportState()
: initialScale(1.0)
, minimumScale(0.25)
, maximumScale(1.8)
, pixelRatio(1.0)
, isUserScalable(true)
{ }
qreal initialScale;
qreal minimumScale;
qreal maximumScale;
qreal pixelRatio;
bool isUserScalable;
} viewport;
QTouchWebView* const q;
QScopedPointer<QTouchWebPage> pageView;
WebKit::TouchViewInterface viewInterface;
QTouchWebPageProxy page;
WebCore::ViewportArguments viewportArguments;
};
#endif /* qtouchwebview_p_h */
......@@ -705,6 +705,11 @@ void QtWebPageProxy::startDrag(const WebCore::DragData& dragData, PassRefPtr<Sha
m_webPageProxy->dragEnded(clientPosition, globalPosition, dropActionToDragOperation(actualDropAction));
}
void QtWebPageProxy::setViewportArguments(const WebCore::ViewportArguments& args)
{
m_viewInterface->didReceiveViewportArguments(args);
}
void QtWebPageProxy::setPageIsVisible(bool isVisible)
{
m_webPageProxy->drawingArea()->setPageIsVisible(isVisible);
......
......@@ -97,6 +97,7 @@ public:
virtual void didChangeContentsSize(const WebCore::IntSize&);
virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
virtual void setViewportArguments(const WebCore::ViewportArguments&);
virtual void setCursor(const WebCore::Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves);
virtual void toolTipChanged(const WTF::String&, const WTF::String&);
......
......@@ -143,6 +143,11 @@ void TouchViewInterface::startDrag(Qt::DropActions supportedDropActions, const Q
Q_ASSERT(false);
}
void TouchViewInterface::didReceiveViewportArguments(const WebCore::ViewportArguments& args)
{
m_viewportView->d->setViewportArguments(args);
}
void TouchViewInterface::didChangeUrl(const QUrl& url)
{
emit m_pageView->urlChanged(url);
......
......@@ -27,6 +27,10 @@ class QPointF;
class QTouchWebPage;
class QTouchWebView;
namespace WebCore {
class ViewportArguments;
}
namespace WebKit {
class SGAgent;
......@@ -59,6 +63,8 @@ private:
virtual bool isVisible();
virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction);
virtual void didReceiveViewportArguments(const WebCore::ViewportArguments&);
virtual void didFindZoomableArea(const QPoint&, const QRect&);
virtual void didChangeUrl(const QUrl&);
......
......@@ -38,6 +38,10 @@ class QUrl;
class QWidget;
QT_END_NAMESPACE
namespace WebCore {
class ViewportArguments;
}
namespace WebKit {
class ViewInterface
......@@ -53,6 +57,8 @@ public:
virtual bool isVisible() = 0;
virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction) = 0;
virtual void didReceiveViewportArguments(const WebCore::ViewportArguments&) = 0;
virtual void didFindZoomableArea(const QPoint&, const QRect&) = 0;
virtual void didChangeUrl(const QUrl&) = 0;
......
......@@ -33,8 +33,6 @@ QTouchWebPageProxy::QTouchWebPageProxy(TouchViewInterface* viewInterface, QWKCon
, m_pinchGestureRecognizer(viewInterface)
{
init();
// FIXME: add proper handling of viewport.
setResizesToContentsUsingLayoutSize(QSize(980, 980));
}
PassOwnPtr<DrawingAreaProxy> QTouchWebPageProxy::createDrawingAreaProxy()
......@@ -54,12 +52,6 @@ void QTouchWebPageProxy::paintContent(QPainter* painter, const QRect& area)
m_webPageProxy->drawingArea()->paint(IntRect(area), painter);
}
void QTouchWebPageProxy::setViewportArguments(const WebCore::ViewportArguments& args)
{
m_viewportArguments = args;
// FIXME: we must tell our Views to react to the new viewport parameters.
}
#if ENABLE(TOUCH_EVENTS)
void QTouchWebPageProxy::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
{
......
......@@ -50,7 +50,6 @@ protected:
private:
virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
virtual void processDidCrash();
virtual void setViewportArguments(const WebCore::ViewportArguments&);
#if ENABLE(TOUCH_EVENTS)
virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
#endif
......@@ -62,7 +61,6 @@ private:
QtPanGestureRecognizer m_panGestureRecognizer;
QtPinchGestureRecognizer m_pinchGestureRecognizer;
WebCore::ViewportArguments m_viewportArguments;
};
#endif /* qtouchwebpageproxy_h */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment