1/*
2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef QWebPageClient_h
27#define QWebPageClient_h
28
29#ifndef QT_NO_CURSOR
30#include <QCursor>
31#endif
32
33#if USE(ACCELERATED_COMPOSITING)
34#include <GraphicsLayer.h>
35#endif
36
37#if USE(3D_GRAPHICS)
38#include <GraphicsContext3D.h>
39#endif
40
41#include <QPalette>
42#include <QRect>
43
44QT_BEGIN_NAMESPACE
45class QStyle;
46class QWindow;
47QT_END_NAMESPACE
48
49namespace WebCore {
50class Widget;
51}
52
53class QWebPageClient {
54public:
55    virtual ~QWebPageClient() { }
56
57    virtual bool isQWidgetClient() const { return false; }
58
59    virtual void scroll(int dx, int dy, const QRect&) = 0;
60    virtual void update(const QRect&) = 0;
61    virtual void repaintViewport() = 0;
62    virtual void setInputMethodEnabled(bool enable) = 0;
63    virtual bool inputMethodEnabled() const = 0;
64    virtual bool makeOpenGLContextCurrentIfAvailable() { return false; }
65
66    virtual void setInputMethodHints(Qt::InputMethodHints hint) = 0;
67
68#ifndef QT_NO_CURSOR
69    inline void resetCursor()
70    {
71        if (!cursor().bitmap() && cursor().shape() == m_lastCursor.shape())
72            return;
73        updateCursor(m_lastCursor);
74    }
75
76    inline void setCursor(const QCursor& cursor)
77    {
78        m_lastCursor = cursor;
79        if (!cursor.bitmap() && cursor.shape() == this->cursor().shape())
80            return;
81        updateCursor(cursor);
82    }
83#endif
84
85    virtual QPalette palette() const = 0;
86    virtual int screenNumber() const = 0;
87    virtual QObject* ownerWidget() const = 0;
88    virtual QRect geometryRelativeToOwnerWidget() const = 0;
89    virtual QPoint mapToOwnerWindow(const QPoint&) const = 0;
90
91    virtual QObject* pluginParent() const = 0;
92
93    virtual QStyle* style() const = 0;
94
95    virtual QRectF graphicsItemVisibleRect() const { return QRectF(); }
96
97    virtual bool viewResizesToContentsEnabled() const = 0;
98
99    virtual QRectF windowRect() const = 0;
100
101    virtual void setWidgetVisible(WebCore::Widget*, bool visible) = 0;
102
103    virtual QWindow* ownerWindow() const;
104
105protected:
106#ifndef QT_NO_CURSOR
107    virtual QCursor cursor() const = 0;
108    virtual void updateCursor(const QCursor& cursor) = 0;
109#endif
110
111private:
112#ifndef QT_NO_CURSOR
113    QCursor m_lastCursor;
114#endif
115};
116
117#endif
118