| Differences between
and this patch
- WebKit/qt/ChangeLog +28 lines
Lines 1-3 WebKit/qt/ChangeLog_sec1
1
2009-11-02  Yael Aharon  <yael.aharon@nokia.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        [Qt] REGRESSION: Allow applications to use their own QWidget bypassing QWebView.
6
        https://bugs.webkit.org/show_bug.cgi?id=30979
7
8
        Decouple QWebViewPrivate from QWebPageClient, and automatically create
9
        QWebPageWidgetClient whenever the view is QWidget based.
10
11
        * Api/qwebpage.cpp:
12
        (QWebPageWidgetClient::QWebPageWidgetClient):
13
        (QWebPageWidgetClient::scroll):
14
        (QWebPageWidgetClient::update):
15
        (QWebPageWidgetClient::setInputMethodEnabled):
16
        (QWebPageWidgetClient::setInputMethodHint):
17
        (QWebPageWidgetClient::cursor):
18
        (QWebPageWidgetClient::updateCursor):
19
        (QWebPageWidgetClient::palette):
20
        (QWebPageWidgetClient::screenNumber):
21
        (QWebPageWidgetClient::ownerWidget):
22
        (QWebPageWidgetClient::pluginParent):
23
        (QWebPage::setView):
24
        * Api/qwebview.cpp:
25
        (QWebView::~QWebView):
26
        (QWebView::setPage):
27
        (QWebView::event):
28
1
2009-11-02  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>
29
2009-11-02  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>
2
30
3
        Reviewed by Adam Barth.
31
        Reviewed by Adam Barth.
- WebKit/qt/Api/qwebpage.cpp +102 lines
Lines 78-83 WebKit/qt/Api/qwebpage.cpp_sec1
78
#include "Cache.h"
78
#include "Cache.h"
79
#include "runtime/InitializeThreading.h"
79
#include "runtime/InitializeThreading.h"
80
#include "PageGroup.h"
80
#include "PageGroup.h"
81
#include "QWebPageClient.h"
81
82
82
#include <QApplication>
83
#include <QApplication>
83
#include <QBasicTimer>
84
#include <QBasicTimer>
Lines 107-112 WebKit/qt/Api/qwebpage.cpp_sec2
107
#else
108
#else
108
#include "qwebnetworkinterface.h"
109
#include "qwebnetworkinterface.h"
109
#endif
110
#endif
111
#if defined(Q_WS_X11)
112
#include <QX11Info>
113
#endif
110
114
111
using namespace WebCore;
115
using namespace WebCore;
112
116
Lines 138-143 WebKit/qt/Api/qwebpage.cpp_sec3
138
    return page->handle()->page->groupName();
142
    return page->handle()->page->groupName();
139
}
143
}
140
144
145
class QWebPageWidgetClient : public QWebPageClient {
146
public:
147
    QWebPageWidgetClient(QWidget* view)
148
        : view(view)
149
    {
150
        Q_ASSERT(view);
151
    }
152
153
    virtual void scroll(int dx, int dy, const QRect&);
154
    virtual void update(const QRect& dirtyRect);
155
    virtual void setInputMethodEnabled(bool enable);
156
#if QT_VERSION >= 0x040600
157
    virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable);
158
#endif
159
160
#ifndef QT_NO_CURSOR
161
    virtual QCursor cursor() const;
162
    virtual void updateCursor(const QCursor& cursor);
163
#endif
164
165
    virtual QPalette palette() const;
166
    virtual int screenNumber() const;
167
    virtual QWidget* ownerWidget() const;
168
169
    virtual QObject* pluginParent() const;
170
171
    QWidget* view;
172
};
173
174
void QWebPageWidgetClient::scroll(int dx, int dy, const QRect& rectToScroll)
175
{
176
    view->scroll(qreal(dx), qreal(dy), rectToScroll);
177
}
178
179
void QWebPageWidgetClient::update(const QRect & dirtyRect)
180
{
181
    view->update(dirtyRect);
182
}
183
184
void QWebPageWidgetClient::setInputMethodEnabled(bool enable)
185
{
186
    view->setAttribute(Qt::WA_InputMethodEnabled, enable);
187
}
188
#if QT_VERSION >= 0x040600
189
void QWebPageWidgetClient::setInputMethodHint(Qt::InputMethodHint hint, bool enable)
190
{
191
    if (enable)
192
        view->setInputMethodHints(view->inputMethodHints() | hint);
193
    else
194
        view->setInputMethodHints(view->inputMethodHints() & ~hint);
195
}
196
#endif
197
#ifndef QT_NO_CURSOR
198
QCursor QWebPageWidgetClient::cursor() const
199
{
200
    return view->cursor();
201
}
202
203
void QWebPageWidgetClient::updateCursor(const QCursor& cursor)
204
{
205
    view->setCursor(cursor);
206
}
207
#endif
208
209
QPalette QWebPageWidgetClient::palette() const
210
{
211
    return view->palette();
212
}
213
214
int QWebPageWidgetClient::screenNumber() const
215
{
216
#if defined(Q_WS_X11)
217
    if (view)
218
        return view->x11Info().screen();
219
#endif
220
221
    return 0;
222
}
223
224
QWidget* QWebPageWidgetClient::ownerWidget() const
225
{
226
    return view;
227
}
228
229
QObject* QWebPageWidgetClient::pluginParent() const
230
{
231
    return view;
232
}
233
141
// Lookup table mapping QWebPage::WebActions to the associated Editor commands
234
// Lookup table mapping QWebPage::WebActions to the associated Editor commands
142
static const char* editorCommandWebActions[] =
235
static const char* editorCommandWebActions[] =
143
{
236
{
Lines 1672-1677 WebKit/qt/Api/qwebpage.cpp_sec4
1672
{
1765
{
1673
    if (this->view() != view) {
1766
    if (this->view() != view) {
1674
        d->view = view;
1767
        d->view = view;
1768
        if (!view) {
1769
            delete d->client;
1770
            d->client = 0;
1771
        } else {
1772
            if (!d->client) 
1773
                d->client = new QWebPageWidgetClient(view);
1774
            else
1775
                static_cast<QWebPageWidgetClient*>(d->client)->view = view;
1776
        }
1675
        setViewportSize(view ? view->size() : QSize(0, 0));
1777
        setViewportSize(view ? view->size() : QSize(0, 0));
1676
    }
1778
    }
1677
}
1779
}
- WebKit/qt/Api/qwebview.cpp -84 / +3 lines
Lines 32-42 WebKit/qt/Api/qwebview.cpp_sec1
32
#include "qprinter.h"
32
#include "qprinter.h"
33
#include "qdir.h"
33
#include "qdir.h"
34
#include "qfile.h"
34
#include "qfile.h"
35
#if defined(Q_WS_X11)
36
#include <QX11Info>
37
#endif
38
35
39
class QWebViewPrivate : public QWebPageClient {
36
class QWebViewPrivate {
40
public:
37
public:
41
    QWebViewPrivate(QWebView *view)
38
    QWebViewPrivate(QWebView *view)
42
        : view(view)
39
        : view(view)
Lines 46-69 WebKit/qt/Api/qwebview.cpp_sec2
46
        Q_ASSERT(view);
43
        Q_ASSERT(view);
47
    }
44
    }
48
45
49
    virtual void scroll(int dx, int dy, const QRect&);
50
    virtual void update(const QRect& dirtyRect);
51
    virtual void setInputMethodEnabled(bool enable);
52
#if QT_VERSION >= 0x040600
53
    virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable);
54
#endif
55
56
#ifndef QT_NO_CURSOR
57
    virtual QCursor cursor() const;
58
    virtual void updateCursor(const QCursor& cursor);
59
#endif
60
61
    virtual QPalette palette() const;
62
    virtual int screenNumber() const;
63
    virtual QWidget* ownerWidget() const;
64
65
    virtual QObject* pluginParent() const;
66
67
    void _q_pageDestroyed();
46
    void _q_pageDestroyed();
68
47
69
    QWebView *view;
48
    QWebView *view;
Lines 72-137 WebKit/qt/Api/qwebview.cpp_sec3
72
    QPainter::RenderHints renderHints;
51
    QPainter::RenderHints renderHints;
73
};
52
};
74
53
75
void QWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
76
{
77
    view->scroll(qreal(dx), qreal(dy), rectToScroll);
78
}
79
80
void QWebViewPrivate::update(const QRect & dirtyRect)
81
{
82
    view->update(dirtyRect);
83
}
84
85
void QWebViewPrivate::setInputMethodEnabled(bool enable)
86
{
87
    view->setAttribute(Qt::WA_InputMethodEnabled, enable);
88
}
89
#if QT_VERSION >= 0x040600
90
void QWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable)
91
{
92
    if (enable)
93
        view->setInputMethodHints(view->inputMethodHints() | hint);
94
    else
95
        view->setInputMethodHints(view->inputMethodHints() & ~hint);
96
}
97
#endif
98
#ifndef QT_NO_CURSOR
99
QCursor QWebViewPrivate::cursor() const
100
{
101
    return view->cursor();
102
}
103
104
void QWebViewPrivate::updateCursor(const QCursor& cursor)
105
{
106
    view->setCursor(cursor);
107
}
108
#endif
109
110
QPalette QWebViewPrivate::palette() const
111
{
112
    return view->palette();
113
}
114
115
int QWebViewPrivate::screenNumber() const
116
{
117
#if defined(Q_WS_X11)
118
    if (view)
119
        return view->x11Info().screen();
120
#endif
121
122
    return 0;
123
}
124
125
QWidget* QWebViewPrivate::ownerWidget() const
126
{
127
    return view;
128
}
129
130
QObject* QWebViewPrivate::pluginParent() const
131
{
132
    return view;
133
}
134
135
void QWebViewPrivate::_q_pageDestroyed()
54
void QWebViewPrivate::_q_pageDestroyed()
136
{
55
{
137
    page = 0;
56
    page = 0;
Lines 251-256 WebKit/qt/Api/qwebview.cpp_sec4
251
#else
170
#else
252
        d->page->d->view = 0;
171
        d->page->d->view = 0;
253
#endif
172
#endif
173
        delete d->page->d->client;
254
        d->page->d->client = 0;
174
        d->page->d->client = 0;
255
    }
175
    }
256
176
Lines 296-302 WebKit/qt/Api/qwebview.cpp_sec5
296
    d->page = page;
216
    d->page = page;
297
    if (d->page) {
217
    if (d->page) {
298
        d->page->setView(this);
218
        d->page->setView(this);
299
        d->page->d->client = d; // set the page client
300
        d->page->setPalette(palette());
219
        d->page->setPalette(palette());
301
        // #### connect signals
220
        // #### connect signals
302
        QWebFrame *mainFrame = d->page->mainFrame();
221
        QWebFrame *mainFrame = d->page->mainFrame();
Lines 728-734 WebKit/qt/Api/qwebview.cpp_sec6
728
            // WebCore.
647
            // WebCore.
729
            // FIXME: Add a QEvent::CursorUnset or similar to Qt.
648
            // FIXME: Add a QEvent::CursorUnset or similar to Qt.
730
            if (cursor().shape() == Qt::ArrowCursor)
649
            if (cursor().shape() == Qt::ArrowCursor)
731
                d->resetCursor();
650
                d->page->d->client->resetCursor();
732
#endif
651
#endif
733
#endif
652
#endif
734
        } else if (e->type() == QEvent::Leave)
653
        } else if (e->type() == QEvent::Leave)

Return to Bug 30979