author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 03 May 2010 13:17:34 +0300 | |
changeset 19 | fcece45ef507 |
parent 18 | 2f34d5167611 |
child 29 | b72c6db6890b |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies) |
|
3 |
Copyright (C) 2007 Staikos Computing Services Inc. |
|
4 |
Copyright (C) 2007 Apple Inc. |
|
5 |
||
6 |
This library is free software; you can redistribute it and/or |
|
7 |
modify it under the terms of the GNU Library General Public |
|
8 |
License as published by the Free Software Foundation; either |
|
9 |
version 2 of the License, or (at your option) any later version. |
|
10 |
||
11 |
This library is distributed in the hope that it will be useful, |
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
Library General Public License for more details. |
|
15 |
||
16 |
You should have received a copy of the GNU Library General Public License |
|
17 |
along with this library; see the file COPYING.LIB. If not, write to |
|
18 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 |
Boston, MA 02110-1301, USA. |
|
20 |
*/ |
|
21 |
||
22 |
#include "config.h" |
|
23 |
#include "qwebpage.h" |
|
24 |
#include "qwebview.h" |
|
25 |
#include "qwebframe.h" |
|
26 |
#include "qwebpage_p.h" |
|
27 |
#include "qwebframe_p.h" |
|
28 |
#include "qwebhistory.h" |
|
29 |
#include "qwebhistory_p.h" |
|
30 |
#include "qwebinspector.h" |
|
31 |
#include "qwebinspector_p.h" |
|
32 |
#include "qwebsettings.h" |
|
33 |
#include "qwebkitversion.h" |
|
34 |
||
35 |
#include "Frame.h" |
|
36 |
#include "FrameTree.h" |
|
37 |
#include "FrameLoader.h" |
|
38 |
#include "FrameLoaderClientQt.h" |
|
39 |
#include "FrameView.h" |
|
40 |
#include "FormState.h" |
|
41 |
#include "ApplicationCacheStorage.h" |
|
42 |
#include "ChromeClientQt.h" |
|
43 |
#include "ContextMenu.h" |
|
44 |
#include "ContextMenuClientQt.h" |
|
45 |
#include "DocumentLoader.h" |
|
46 |
#include "DragClientQt.h" |
|
47 |
#include "DragController.h" |
|
48 |
#include "DragData.h" |
|
49 |
#include "EditorClientQt.h" |
|
50 |
#include "SecurityOrigin.h" |
|
51 |
#include "Settings.h" |
|
52 |
#include "Page.h" |
|
53 |
#include "Pasteboard.h" |
|
54 |
#include "FrameLoader.h" |
|
55 |
#include "FrameLoadRequest.h" |
|
56 |
#include "KURL.h" |
|
57 |
#include "Logging.h" |
|
58 |
#include "Image.h" |
|
59 |
#include "InspectorClientQt.h" |
|
60 |
#include "InspectorController.h" |
|
61 |
#include "FocusController.h" |
|
62 |
#include "Editor.h" |
|
63 |
#include "Scrollbar.h" |
|
64 |
#include "PlatformKeyboardEvent.h" |
|
65 |
#include "PlatformWheelEvent.h" |
|
66 |
#include "PluginDatabase.h" |
|
67 |
#include "ProgressTracker.h" |
|
68 |
#include "RefPtr.h" |
|
69 |
#include "RenderTextControl.h" |
|
70 |
#include "TextIterator.h" |
|
71 |
#include "HashMap.h" |
|
72 |
#include "HTMLFormElement.h" |
|
73 |
#include "HTMLInputElement.h" |
|
74 |
#include "HTMLNames.h" |
|
75 |
#include "HitTestResult.h" |
|
76 |
#include "WindowFeatures.h" |
|
77 |
#include "LocalizedStrings.h" |
|
78 |
#include "Cache.h" |
|
79 |
#include "runtime/InitializeThreading.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
#include "PageGroup.h" |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
#include "QWebPageClient.h" |
0 | 82 |
|
83 |
#include <QApplication> |
|
84 |
#include <QBasicTimer> |
|
85 |
#include <QBitArray> |
|
86 |
#include <QDebug> |
|
87 |
#include <QDragEnterEvent> |
|
88 |
#include <QDragLeaveEvent> |
|
89 |
#include <QDragMoveEvent> |
|
90 |
#include <QDropEvent> |
|
91 |
#include <QFileDialog> |
|
92 |
#include <QHttpRequestHeader> |
|
93 |
#include <QInputDialog> |
|
94 |
#include <QLocale> |
|
95 |
#include <QMessageBox> |
|
96 |
#include <QNetworkProxy> |
|
97 |
#include <QUndoStack> |
|
98 |
#include <QUrl> |
|
99 |
#include <QPainter> |
|
100 |
#include <QClipboard> |
|
101 |
#include <QSslSocket> |
|
102 |
#include <QStyle> |
|
103 |
#include <QSysInfo> |
|
104 |
#include <QTextCharFormat> |
|
105 |
#if QT_VERSION >= 0x040400 |
|
106 |
#include <QNetworkAccessManager> |
|
107 |
#include <QNetworkRequest> |
|
108 |
#else |
|
109 |
#include "qwebnetworkinterface.h" |
|
110 |
#endif |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
#if defined(Q_WS_X11) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
#include <QX11Info> |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
#endif |
0 | 114 |
|
115 |
using namespace WebCore; |
|
116 |
||
117 |
void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories() |
|
118 |
{ |
|
119 |
PluginDatabase* db = PluginDatabase::installedPlugins(/* populate */ false); |
|
120 |
||
121 |
Vector<String> paths; |
|
122 |
String qtPath(qgetenv("QTWEBKIT_PLUGIN_PATH").data()); |
|
123 |
qtPath.split(UChar(':'), /* allowEmptyEntries */ false, paths); |
|
124 |
||
125 |
db->setPluginDirectories(paths); |
|
126 |
db->refresh(); |
|
127 |
} |
|
128 |
||
129 |
bool QWebPagePrivate::drtRun = false; |
|
130 |
void QWEBKIT_EXPORT qt_drt_run(bool b) |
|
131 |
{ |
|
132 |
QWebPagePrivate::drtRun = b; |
|
133 |
} |
|
134 |
||
135 |
void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName) |
|
136 |
{ |
|
137 |
page->handle()->page->setGroupName(groupName); |
|
138 |
} |
|
139 |
||
140 |
QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page) |
|
141 |
{ |
|
142 |
return page->handle()->page->groupName(); |
|
143 |
} |
|
144 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
class QWebPageWidgetClient : public QWebPageClient { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
public: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
QWebPageWidgetClient(QWidget* view) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
: view(view) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
Q_ASSERT(view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
virtual void scroll(int dx, int dy, const QRect&); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
154 |
virtual void update(const QRect& dirtyRect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
virtual void setInputMethodEnabled(bool enable); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
156 |
virtual bool inputMethodEnabled() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
#if QT_VERSION >= 0x040600 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
158 |
virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
#ifndef QT_NO_CURSOR |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
virtual QCursor cursor() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
virtual void updateCursor(const QCursor& cursor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
virtual QPalette palette() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
virtual int screenNumber() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
virtual QWidget* ownerWidget() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
virtual QObject* pluginParent() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
QWidget* view; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
}; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
void QWebPageWidgetClient::scroll(int dx, int dy, const QRect& rectToScroll) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
view->scroll(qreal(dx), qreal(dy), rectToScroll); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
void QWebPageWidgetClient::update(const QRect & dirtyRect) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
view->update(dirtyRect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
183 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
void QWebPageWidgetClient::setInputMethodEnabled(bool enable) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
view->setAttribute(Qt::WA_InputMethodEnabled, enable); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
bool QWebPageWidgetClient::inputMethodEnabled() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
return view->testAttribute(Qt::WA_InputMethodEnabled); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
#if QT_VERSION >= 0x040600 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
void QWebPageWidgetClient::setInputMethodHint(Qt::InputMethodHint hint, bool enable) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
if (enable) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
view->setInputMethodHints(view->inputMethodHints() | hint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
view->setInputMethodHints(view->inputMethodHints() & ~hint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
#ifndef QT_NO_CURSOR |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
QCursor QWebPageWidgetClient::cursor() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
return view->cursor(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
void QWebPageWidgetClient::updateCursor(const QCursor& cursor) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
view->setCursor(cursor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
QPalette QWebPageWidgetClient::palette() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
return view->palette(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
int QWebPageWidgetClient::screenNumber() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
#if defined(Q_WS_X11) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
if (view) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
return view->x11Info().screen(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
226 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
227 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
return 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
QWidget* QWebPageWidgetClient::ownerWidget() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
return view; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
234 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
QObject* QWebPageWidgetClient::pluginParent() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
return view; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
|
0 | 241 |
// Lookup table mapping QWebPage::WebActions to the associated Editor commands |
242 |
static const char* editorCommandWebActions[] = |
|
243 |
{ |
|
244 |
0, // OpenLink, |
|
245 |
||
246 |
0, // OpenLinkInNewWindow, |
|
247 |
0, // OpenFrameInNewWindow, |
|
248 |
||
249 |
0, // DownloadLinkToDisk, |
|
250 |
0, // CopyLinkToClipboard, |
|
251 |
||
252 |
0, // OpenImageInNewWindow, |
|
253 |
0, // DownloadImageToDisk, |
|
254 |
0, // CopyImageToClipboard, |
|
255 |
||
256 |
0, // Back, |
|
257 |
0, // Forward, |
|
258 |
0, // Stop, |
|
259 |
0, // Reload, |
|
260 |
||
261 |
"Cut", // Cut, |
|
262 |
"Copy", // Copy, |
|
263 |
"Paste", // Paste, |
|
264 |
||
265 |
"Undo", // Undo, |
|
266 |
"Redo", // Redo, |
|
267 |
"MoveForward", // MoveToNextChar, |
|
268 |
"MoveBackward", // MoveToPreviousChar, |
|
269 |
"MoveWordForward", // MoveToNextWord, |
|
270 |
"MoveWordBackward", // MoveToPreviousWord, |
|
271 |
"MoveDown", // MoveToNextLine, |
|
272 |
"MoveUp", // MoveToPreviousLine, |
|
273 |
"MoveToBeginningOfLine", // MoveToStartOfLine, |
|
274 |
"MoveToEndOfLine", // MoveToEndOfLine, |
|
275 |
"MoveToBeginningOfParagraph", // MoveToStartOfBlock, |
|
276 |
"MoveToEndOfParagraph", // MoveToEndOfBlock, |
|
277 |
"MoveToBeginningOfDocument", // MoveToStartOfDocument, |
|
278 |
"MoveToEndOfDocument", // MoveToEndOfDocument, |
|
279 |
"MoveForwardAndModifySelection", // SelectNextChar, |
|
280 |
"MoveBackwardAndModifySelection", // SelectPreviousChar, |
|
281 |
"MoveWordForwardAndModifySelection", // SelectNextWord, |
|
282 |
"MoveWordBackwardAndModifySelection", // SelectPreviousWord, |
|
283 |
"MoveDownAndModifySelection", // SelectNextLine, |
|
284 |
"MoveUpAndModifySelection", // SelectPreviousLine, |
|
285 |
"MoveToBeginningOfLineAndModifySelection", // SelectStartOfLine, |
|
286 |
"MoveToEndOfLineAndModifySelection", // SelectEndOfLine, |
|
287 |
"MoveToBeginningOfParagraphAndModifySelection", // SelectStartOfBlock, |
|
288 |
"MoveToEndOfParagraphAndModifySelection", // SelectEndOfBlock, |
|
289 |
"MoveToBeginningOfDocumentAndModifySelection", //SelectStartOfDocument, |
|
290 |
"MoveToEndOfDocumentAndModifySelection", // SelectEndOfDocument, |
|
291 |
"DeleteWordBackward", // DeleteStartOfWord, |
|
292 |
"DeleteWordForward", // DeleteEndOfWord, |
|
293 |
||
294 |
0, // SetTextDirectionDefault, |
|
295 |
0, // SetTextDirectionLeftToRight, |
|
296 |
0, // SetTextDirectionRightToLeft, |
|
297 |
||
298 |
"ToggleBold", // ToggleBold, |
|
299 |
"ToggleItalic", // ToggleItalic, |
|
300 |
"ToggleUnderline", // ToggleUnderline, |
|
301 |
||
302 |
0, // InspectElement, |
|
303 |
||
304 |
"InsertNewline", // InsertParagraphSeparator |
|
305 |
"InsertLineBreak", // InsertLineSeparator |
|
306 |
||
307 |
"SelectAll", // SelectAll |
|
308 |
0, // ReloadAndBypassCache, |
|
309 |
||
310 |
"PasteAndMatchStyle", // PasteAndMatchStyle |
|
311 |
"RemoveFormat", // RemoveFormat |
|
312 |
"Strikethrough", // ToggleStrikethrough, |
|
313 |
"Subscript", // ToggleSubscript |
|
314 |
"Superscript", // ToggleSuperscript |
|
315 |
"InsertUnorderedList", // InsertUnorderedList |
|
316 |
"InsertOrderedList", // InsertOrderedList |
|
317 |
"Indent", // Indent |
|
318 |
"Outdent", // Outdent, |
|
319 |
||
320 |
"AlignCenter", // AlignCenter, |
|
321 |
"AlignJustified", // AlignJustified, |
|
322 |
"AlignLeft", // AlignLeft, |
|
323 |
"AlignRight", // AlignRight, |
|
324 |
||
325 |
0 // WebActionCount |
|
326 |
}; |
|
327 |
||
328 |
// Lookup the appropriate editor command to use for WebAction \a action |
|
329 |
const char* QWebPagePrivate::editorCommandForWebActions(QWebPage::WebAction action) |
|
330 |
{ |
|
331 |
if ((action > QWebPage::NoWebAction) && (action < int(sizeof(editorCommandWebActions) / sizeof(const char*)))) |
|
332 |
return editorCommandWebActions[action]; |
|
333 |
return 0; |
|
334 |
} |
|
335 |
||
336 |
// If you change this make sure to also adjust the docs for QWebPage::userAgentForUrl |
|
337 |
#define WEBKIT_VERSION "527+" |
|
338 |
||
339 |
static inline DragOperation dropActionToDragOp(Qt::DropActions actions) |
|
340 |
{ |
|
341 |
unsigned result = 0; |
|
342 |
if (actions & Qt::CopyAction) |
|
343 |
result |= DragOperationCopy; |
|
344 |
if (actions & Qt::MoveAction) |
|
345 |
result |= DragOperationMove; |
|
346 |
if (actions & Qt::LinkAction) |
|
347 |
result |= DragOperationLink; |
|
348 |
return (DragOperation)result; |
|
349 |
} |
|
350 |
||
351 |
static inline Qt::DropAction dragOpToDropAction(unsigned actions) |
|
352 |
{ |
|
353 |
Qt::DropAction result = Qt::IgnoreAction; |
|
354 |
if (actions & DragOperationCopy) |
|
355 |
result = Qt::CopyAction; |
|
356 |
else if (actions & DragOperationMove) |
|
357 |
result = Qt::MoveAction; |
|
358 |
else if (actions & DragOperationLink) |
|
359 |
result = Qt::LinkAction; |
|
360 |
return result; |
|
361 |
} |
|
362 |
||
363 |
QWebPagePrivate::QWebPagePrivate(QWebPage *qq) |
|
364 |
: q(qq) |
|
365 |
, client(0) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
366 |
#if QT_VERSION < 0x040600 |
0 | 367 |
, view(0) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
368 |
#endif |
0 | 369 |
, inspectorFrontend(0) |
370 |
, inspector(0) |
|
371 |
, inspectorIsInternalOnly(false) |
|
372 |
, viewportSize(QSize(0, 0)) |
|
373 |
, clickCausedFocus(false) |
|
374 |
{ |
|
375 |
WebCore::InitializeLoggingChannelsIfNecessary(); |
|
376 |
JSC::initializeThreading(); |
|
377 |
WebCore::SecurityOrigin::setLocalLoadPolicy(WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData); |
|
378 |
||
379 |
chromeClient = new ChromeClientQt(q); |
|
380 |
contextMenuClient = new ContextMenuClientQt(); |
|
381 |
editorClient = new EditorClientQt(q); |
|
382 |
page = new Page(chromeClient, contextMenuClient, editorClient, |
|
383 |
new DragClientQt(q), new InspectorClientQt(q), 0); |
|
384 |
||
385 |
settings = new QWebSettings(page->settings()); |
|
386 |
||
387 |
#ifndef QT_NO_UNDOSTACK |
|
388 |
undoStack = 0; |
|
389 |
#endif |
|
390 |
mainFrame = 0; |
|
391 |
#if QT_VERSION < 0x040400 |
|
392 |
networkInterface = 0; |
|
393 |
#else |
|
394 |
networkManager = 0; |
|
395 |
#endif |
|
396 |
pluginFactory = 0; |
|
397 |
insideOpenCall = false; |
|
398 |
forwardUnsupportedContent = false; |
|
399 |
editable = false; |
|
400 |
useFixedLayout = false; |
|
401 |
linkPolicy = QWebPage::DontDelegateLinks; |
|
402 |
#ifndef QT_NO_CONTEXTMENU |
|
403 |
currentContextMenu = 0; |
|
404 |
#endif |
|
405 |
||
406 |
history.d = new QWebHistoryPrivate(page->backForwardList()); |
|
407 |
memset(actions, 0, sizeof(actions)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
408 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
409 |
PageGroup::setShouldTrackVisitedLinks(true); |
0 | 410 |
} |
411 |
||
412 |
QWebPagePrivate::~QWebPagePrivate() |
|
413 |
{ |
|
414 |
#ifndef QT_NO_CONTEXTMENU |
|
415 |
delete currentContextMenu; |
|
416 |
#endif |
|
417 |
#ifndef QT_NO_UNDOSTACK |
|
418 |
delete undoStack; |
|
419 |
#endif |
|
420 |
delete settings; |
|
421 |
delete page; |
|
422 |
} |
|
423 |
||
424 |
#if QT_VERSION < 0x040400 |
|
425 |
bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type) |
|
426 |
{ |
|
427 |
if (insideOpenCall |
|
428 |
&& frame == mainFrame) |
|
429 |
return true; |
|
430 |
return q->acceptNavigationRequest(frame, request, type); |
|
431 |
} |
|
432 |
#else |
|
433 |
bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) |
|
434 |
{ |
|
435 |
if (insideOpenCall |
|
436 |
&& frame == mainFrame) |
|
437 |
return true; |
|
438 |
return q->acceptNavigationRequest(frame, request, type); |
|
439 |
} |
|
440 |
#endif |
|
441 |
||
442 |
void QWebPagePrivate::createMainFrame() |
|
443 |
{ |
|
444 |
if (!mainFrame) { |
|
445 |
QWebFrameData frameData(page); |
|
446 |
mainFrame = new QWebFrame(q, &frameData); |
|
447 |
||
448 |
emit q->frameCreated(mainFrame); |
|
449 |
} |
|
450 |
} |
|
451 |
||
452 |
static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAction action) |
|
453 |
{ |
|
454 |
switch (action) { |
|
455 |
case WebCore::ContextMenuItemTagOpenLink: return QWebPage::OpenLink; |
|
456 |
case WebCore::ContextMenuItemTagOpenLinkInNewWindow: return QWebPage::OpenLinkInNewWindow; |
|
457 |
case WebCore::ContextMenuItemTagDownloadLinkToDisk: return QWebPage::DownloadLinkToDisk; |
|
458 |
case WebCore::ContextMenuItemTagCopyLinkToClipboard: return QWebPage::CopyLinkToClipboard; |
|
459 |
case WebCore::ContextMenuItemTagOpenImageInNewWindow: return QWebPage::OpenImageInNewWindow; |
|
460 |
case WebCore::ContextMenuItemTagDownloadImageToDisk: return QWebPage::DownloadImageToDisk; |
|
461 |
case WebCore::ContextMenuItemTagCopyImageToClipboard: return QWebPage::CopyImageToClipboard; |
|
462 |
case WebCore::ContextMenuItemTagOpenFrameInNewWindow: return QWebPage::OpenFrameInNewWindow; |
|
463 |
case WebCore::ContextMenuItemTagCopy: return QWebPage::Copy; |
|
464 |
case WebCore::ContextMenuItemTagGoBack: return QWebPage::Back; |
|
465 |
case WebCore::ContextMenuItemTagGoForward: return QWebPage::Forward; |
|
466 |
case WebCore::ContextMenuItemTagStop: return QWebPage::Stop; |
|
467 |
case WebCore::ContextMenuItemTagReload: return QWebPage::Reload; |
|
468 |
case WebCore::ContextMenuItemTagCut: return QWebPage::Cut; |
|
469 |
case WebCore::ContextMenuItemTagPaste: return QWebPage::Paste; |
|
470 |
case WebCore::ContextMenuItemTagDefaultDirection: return QWebPage::SetTextDirectionDefault; |
|
471 |
case WebCore::ContextMenuItemTagLeftToRight: return QWebPage::SetTextDirectionLeftToRight; |
|
472 |
case WebCore::ContextMenuItemTagRightToLeft: return QWebPage::SetTextDirectionRightToLeft; |
|
473 |
case WebCore::ContextMenuItemTagBold: return QWebPage::ToggleBold; |
|
474 |
case WebCore::ContextMenuItemTagItalic: return QWebPage::ToggleItalic; |
|
475 |
case WebCore::ContextMenuItemTagUnderline: return QWebPage::ToggleUnderline; |
|
476 |
case WebCore::ContextMenuItemTagInspectElement: return QWebPage::InspectElement; |
|
477 |
default: break; |
|
478 |
} |
|
479 |
return QWebPage::NoWebAction; |
|
480 |
} |
|
481 |
||
482 |
#ifndef QT_NO_CONTEXTMENU |
|
483 |
QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu, |
|
484 |
const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions) |
|
485 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
486 |
QMenu* menu = new QMenu(q->view()); |
0 | 487 |
for (int i = 0; i < items->count(); ++i) { |
488 |
const ContextMenuItem &item = items->at(i); |
|
489 |
switch (item.type()) { |
|
490 |
case WebCore::CheckableActionType: /* fall through */ |
|
491 |
case WebCore::ActionType: { |
|
492 |
QWebPage::WebAction action = webActionForContextMenuAction(item.action()); |
|
493 |
QAction *a = q->action(action); |
|
494 |
if (a) { |
|
495 |
ContextMenuItem it(item); |
|
496 |
webcoreMenu->checkOrEnableIfNeeded(it); |
|
497 |
PlatformMenuItemDescription desc = it.releasePlatformDescription(); |
|
498 |
a->setEnabled(desc.enabled); |
|
499 |
a->setChecked(desc.checked); |
|
500 |
a->setCheckable(item.type() == WebCore::CheckableActionType); |
|
501 |
||
502 |
menu->addAction(a); |
|
503 |
visitedWebActions->setBit(action); |
|
504 |
} |
|
505 |
break; |
|
506 |
} |
|
507 |
case WebCore::SeparatorType: |
|
508 |
menu->addSeparator(); |
|
509 |
break; |
|
510 |
case WebCore::SubmenuType: { |
|
511 |
QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions); |
|
512 |
||
513 |
bool anyEnabledAction = false; |
|
514 |
||
515 |
QList<QAction *> actions = subMenu->actions(); |
|
516 |
for (int i = 0; i < actions.count(); ++i) { |
|
517 |
if (actions.at(i)->isVisible()) |
|
518 |
anyEnabledAction |= actions.at(i)->isEnabled(); |
|
519 |
} |
|
520 |
||
521 |
// don't show sub-menus with just disabled actions |
|
522 |
if (anyEnabledAction) { |
|
523 |
subMenu->setTitle(item.title()); |
|
524 |
menu->addAction(subMenu->menuAction()); |
|
525 |
} else |
|
526 |
delete subMenu; |
|
527 |
break; |
|
528 |
} |
|
529 |
} |
|
530 |
} |
|
531 |
return menu; |
|
532 |
} |
|
533 |
#endif // QT_NO_CONTEXTMENU |
|
534 |
||
535 |
void QWebPagePrivate::_q_webActionTriggered(bool checked) |
|
536 |
{ |
|
537 |
QAction *a = qobject_cast<QAction *>(q->sender()); |
|
538 |
if (!a) |
|
539 |
return; |
|
540 |
QWebPage::WebAction action = static_cast<QWebPage::WebAction>(a->data().toInt()); |
|
541 |
q->triggerAction(action, checked); |
|
542 |
} |
|
543 |
||
544 |
void QWebPagePrivate::_q_cleanupLeakMessages() |
|
545 |
{ |
|
546 |
#ifndef NDEBUG |
|
547 |
// Need this to make leak messages accurate. |
|
548 |
cache()->setCapacities(0, 0, 0); |
|
549 |
#endif |
|
550 |
} |
|
551 |
||
552 |
void QWebPagePrivate::updateAction(QWebPage::WebAction action) |
|
553 |
{ |
|
554 |
QAction *a = actions[action]; |
|
555 |
if (!a || !mainFrame) |
|
556 |
return; |
|
557 |
||
558 |
WebCore::FrameLoader *loader = mainFrame->d->frame->loader(); |
|
559 |
WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor(); |
|
560 |
||
561 |
bool enabled = a->isEnabled(); |
|
562 |
bool checked = a->isChecked(); |
|
563 |
||
564 |
switch (action) { |
|
565 |
case QWebPage::Back: |
|
566 |
enabled = page->canGoBackOrForward(-1); |
|
567 |
break; |
|
568 |
case QWebPage::Forward: |
|
569 |
enabled = page->canGoBackOrForward(1); |
|
570 |
break; |
|
571 |
case QWebPage::Stop: |
|
572 |
enabled = loader->isLoading(); |
|
573 |
break; |
|
574 |
case QWebPage::Reload: |
|
575 |
case QWebPage::ReloadAndBypassCache: |
|
576 |
enabled = !loader->isLoading(); |
|
577 |
break; |
|
578 |
#ifndef QT_NO_UNDOSTACK |
|
579 |
case QWebPage::Undo: |
|
580 |
case QWebPage::Redo: |
|
581 |
// those two are handled by QUndoStack |
|
582 |
break; |
|
583 |
#endif // QT_NO_UNDOSTACK |
|
584 |
case QWebPage::SelectAll: // editor command is always enabled |
|
585 |
break; |
|
586 |
case QWebPage::SetTextDirectionDefault: |
|
587 |
case QWebPage::SetTextDirectionLeftToRight: |
|
588 |
case QWebPage::SetTextDirectionRightToLeft: |
|
589 |
enabled = editor->canEdit(); |
|
590 |
checked = false; |
|
591 |
break; |
|
592 |
default: { |
|
593 |
// see if it's an editor command |
|
594 |
const char* commandName = editorCommandForWebActions(action); |
|
595 |
||
596 |
// if it's an editor command, let it's logic determine state |
|
597 |
if (commandName) { |
|
598 |
Editor::Command command = editor->command(commandName); |
|
599 |
enabled = command.isEnabled(); |
|
600 |
if (enabled) |
|
601 |
checked = command.state() != FalseTriState; |
|
602 |
else |
|
603 |
checked = false; |
|
604 |
} |
|
605 |
break; |
|
606 |
} |
|
607 |
} |
|
608 |
||
609 |
a->setEnabled(enabled); |
|
610 |
||
611 |
if (a->isCheckable()) |
|
612 |
a->setChecked(checked); |
|
613 |
} |
|
614 |
||
615 |
void QWebPagePrivate::updateNavigationActions() |
|
616 |
{ |
|
617 |
updateAction(QWebPage::Back); |
|
618 |
updateAction(QWebPage::Forward); |
|
619 |
updateAction(QWebPage::Stop); |
|
620 |
updateAction(QWebPage::Reload); |
|
621 |
updateAction(QWebPage::ReloadAndBypassCache); |
|
622 |
} |
|
623 |
||
624 |
void QWebPagePrivate::updateEditorActions() |
|
625 |
{ |
|
626 |
updateAction(QWebPage::Cut); |
|
627 |
updateAction(QWebPage::Copy); |
|
628 |
updateAction(QWebPage::Paste); |
|
629 |
updateAction(QWebPage::MoveToNextChar); |
|
630 |
updateAction(QWebPage::MoveToPreviousChar); |
|
631 |
updateAction(QWebPage::MoveToNextWord); |
|
632 |
updateAction(QWebPage::MoveToPreviousWord); |
|
633 |
updateAction(QWebPage::MoveToNextLine); |
|
634 |
updateAction(QWebPage::MoveToPreviousLine); |
|
635 |
updateAction(QWebPage::MoveToStartOfLine); |
|
636 |
updateAction(QWebPage::MoveToEndOfLine); |
|
637 |
updateAction(QWebPage::MoveToStartOfBlock); |
|
638 |
updateAction(QWebPage::MoveToEndOfBlock); |
|
639 |
updateAction(QWebPage::MoveToStartOfDocument); |
|
640 |
updateAction(QWebPage::MoveToEndOfDocument); |
|
641 |
updateAction(QWebPage::SelectNextChar); |
|
642 |
updateAction(QWebPage::SelectPreviousChar); |
|
643 |
updateAction(QWebPage::SelectNextWord); |
|
644 |
updateAction(QWebPage::SelectPreviousWord); |
|
645 |
updateAction(QWebPage::SelectNextLine); |
|
646 |
updateAction(QWebPage::SelectPreviousLine); |
|
647 |
updateAction(QWebPage::SelectStartOfLine); |
|
648 |
updateAction(QWebPage::SelectEndOfLine); |
|
649 |
updateAction(QWebPage::SelectStartOfBlock); |
|
650 |
updateAction(QWebPage::SelectEndOfBlock); |
|
651 |
updateAction(QWebPage::SelectStartOfDocument); |
|
652 |
updateAction(QWebPage::SelectEndOfDocument); |
|
653 |
updateAction(QWebPage::DeleteStartOfWord); |
|
654 |
updateAction(QWebPage::DeleteEndOfWord); |
|
655 |
updateAction(QWebPage::SetTextDirectionDefault); |
|
656 |
updateAction(QWebPage::SetTextDirectionLeftToRight); |
|
657 |
updateAction(QWebPage::SetTextDirectionRightToLeft); |
|
658 |
updateAction(QWebPage::ToggleBold); |
|
659 |
updateAction(QWebPage::ToggleItalic); |
|
660 |
updateAction(QWebPage::ToggleUnderline); |
|
661 |
updateAction(QWebPage::InsertParagraphSeparator); |
|
662 |
updateAction(QWebPage::InsertLineSeparator); |
|
663 |
updateAction(QWebPage::PasteAndMatchStyle); |
|
664 |
updateAction(QWebPage::RemoveFormat); |
|
665 |
updateAction(QWebPage::ToggleStrikethrough); |
|
666 |
updateAction(QWebPage::ToggleSubscript); |
|
667 |
updateAction(QWebPage::ToggleSuperscript); |
|
668 |
updateAction(QWebPage::InsertUnorderedList); |
|
669 |
updateAction(QWebPage::InsertOrderedList); |
|
670 |
updateAction(QWebPage::Indent); |
|
671 |
updateAction(QWebPage::Outdent); |
|
672 |
updateAction(QWebPage::AlignCenter); |
|
673 |
updateAction(QWebPage::AlignJustified); |
|
674 |
updateAction(QWebPage::AlignLeft); |
|
675 |
updateAction(QWebPage::AlignRight); |
|
676 |
} |
|
677 |
||
678 |
void QWebPagePrivate::timerEvent(QTimerEvent *ev) |
|
679 |
{ |
|
680 |
int timerId = ev->timerId(); |
|
681 |
if (timerId == tripleClickTimer.timerId()) |
|
682 |
tripleClickTimer.stop(); |
|
683 |
else |
|
684 |
q->QObject::timerEvent(ev); |
|
685 |
} |
|
686 |
||
687 |
void QWebPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) |
|
688 |
{ |
|
689 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
690 |
if (!frame->view()) |
|
691 |
return; |
|
692 |
||
693 |
bool accepted = frame->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0)); |
|
694 |
ev->setAccepted(accepted); |
|
695 |
} |
|
696 |
||
697 |
void QWebPagePrivate::mouseMoveEvent(QMouseEvent *ev) |
|
698 |
{ |
|
699 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
700 |
if (!frame->view()) |
|
701 |
return; |
|
702 |
||
703 |
bool accepted = frame->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0)); |
|
704 |
ev->setAccepted(accepted); |
|
705 |
} |
|
706 |
||
707 |
void QWebPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev) |
|
708 |
{ |
|
709 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
710 |
if (!frame->view()) |
|
711 |
return; |
|
712 |
||
713 |
if (tripleClickTimer.isActive() |
|
714 |
&& (ev->pos().toPoint() - tripleClick).manhattanLength() |
|
715 |
< QApplication::startDragDistance()) { |
|
716 |
mouseTripleClickEvent(ev); |
|
717 |
return; |
|
718 |
} |
|
719 |
||
720 |
bool accepted = false; |
|
721 |
PlatformMouseEvent mev(ev, 1); |
|
722 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
723 |
if (mev.button() != NoButton) |
|
724 |
accepted = frame->eventHandler()->handleMousePressEvent(mev); |
|
725 |
ev->setAccepted(accepted); |
|
726 |
} |
|
727 |
||
728 |
void QWebPagePrivate::mousePressEvent(QMouseEvent *ev) |
|
729 |
{ |
|
730 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
731 |
if (!frame->view()) |
|
732 |
return; |
|
733 |
||
734 |
RefPtr<WebCore::Node> oldNode; |
|
735 |
if (page->focusController()->focusedFrame() |
|
736 |
&& page->focusController()->focusedFrame()->document()) |
|
737 |
oldNode = page->focusController()->focusedFrame()->document()->focusedNode(); |
|
738 |
||
739 |
if (tripleClickTimer.isActive() |
|
740 |
&& (ev->pos() - tripleClick).manhattanLength() |
|
741 |
< QApplication::startDragDistance()) { |
|
742 |
mouseTripleClickEvent(ev); |
|
743 |
return; |
|
744 |
} |
|
745 |
||
746 |
bool accepted = false; |
|
747 |
PlatformMouseEvent mev(ev, 1); |
|
748 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
749 |
if (mev.button() != NoButton) |
|
750 |
accepted = frame->eventHandler()->handleMousePressEvent(mev); |
|
751 |
ev->setAccepted(accepted); |
|
752 |
||
753 |
RefPtr<WebCore::Node> newNode; |
|
754 |
if (page->focusController()->focusedFrame() |
|
755 |
&& page->focusController()->focusedFrame()->document()) |
|
756 |
newNode = page->focusController()->focusedFrame()->document()->focusedNode(); |
|
757 |
||
758 |
if (newNode && oldNode != newNode) |
|
759 |
clickCausedFocus = true; |
|
760 |
} |
|
761 |
||
762 |
void QWebPagePrivate::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *ev) |
|
763 |
{ |
|
764 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
765 |
if (!frame->view()) |
|
766 |
return; |
|
767 |
||
768 |
bool accepted = false; |
|
769 |
PlatformMouseEvent mev(ev, 2); |
|
770 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
771 |
if (mev.button() != NoButton) |
|
772 |
accepted = frame->eventHandler()->handleMousePressEvent(mev); |
|
773 |
ev->setAccepted(accepted); |
|
774 |
||
775 |
tripleClickTimer.start(QApplication::doubleClickInterval(), q); |
|
776 |
tripleClick = ev->pos().toPoint(); |
|
777 |
} |
|
778 |
||
779 |
void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev) |
|
780 |
{ |
|
781 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
782 |
if (!frame->view()) |
|
783 |
return; |
|
784 |
||
785 |
bool accepted = false; |
|
786 |
PlatformMouseEvent mev(ev, 2); |
|
787 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
788 |
if (mev.button() != NoButton) |
|
789 |
accepted = frame->eventHandler()->handleMousePressEvent(mev); |
|
790 |
ev->setAccepted(accepted); |
|
791 |
||
792 |
tripleClickTimer.start(QApplication::doubleClickInterval(), q); |
|
793 |
tripleClick = ev->pos(); |
|
794 |
} |
|
795 |
||
796 |
void QWebPagePrivate::mouseTripleClickEvent(QGraphicsSceneMouseEvent *ev) |
|
797 |
{ |
|
798 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
799 |
if (!frame->view()) |
|
800 |
return; |
|
801 |
||
802 |
bool accepted = false; |
|
803 |
PlatformMouseEvent mev(ev, 3); |
|
804 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
805 |
if (mev.button() != NoButton) |
|
806 |
accepted = frame->eventHandler()->handleMousePressEvent(mev); |
|
807 |
ev->setAccepted(accepted); |
|
808 |
} |
|
809 |
||
810 |
void QWebPagePrivate::mouseTripleClickEvent(QMouseEvent *ev) |
|
811 |
{ |
|
812 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
813 |
if (!frame->view()) |
|
814 |
return; |
|
815 |
||
816 |
bool accepted = false; |
|
817 |
PlatformMouseEvent mev(ev, 3); |
|
818 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
819 |
if (mev.button() != NoButton) |
|
820 |
accepted = frame->eventHandler()->handleMousePressEvent(mev); |
|
821 |
ev->setAccepted(accepted); |
|
822 |
} |
|
823 |
||
824 |
void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button) |
|
825 |
{ |
|
826 |
#ifndef QT_NO_CLIPBOARD |
|
827 |
if (QApplication::clipboard()->supportsSelection()) { |
|
828 |
bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode(); |
|
829 |
Pasteboard::generalPasteboard()->setSelectionMode(true); |
|
830 |
WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame(); |
|
831 |
if (button == Qt::LeftButton) { |
|
832 |
if (focusFrame && (focusFrame->editor()->canCopy() || focusFrame->editor()->canDHTMLCopy())) { |
|
833 |
focusFrame->editor()->copy(); |
|
834 |
ev->setAccepted(true); |
|
835 |
} |
|
836 |
} else if (button == Qt::MidButton) { |
|
837 |
if (focusFrame && (focusFrame->editor()->canPaste() || focusFrame->editor()->canDHTMLPaste())) { |
|
838 |
focusFrame->editor()->paste(); |
|
839 |
ev->setAccepted(true); |
|
840 |
} |
|
841 |
} |
|
842 |
Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode); |
|
843 |
} |
|
844 |
#endif |
|
845 |
} |
|
846 |
||
847 |
void QWebPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) |
|
848 |
{ |
|
849 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
850 |
if (!frame->view()) |
|
851 |
return; |
|
852 |
||
853 |
bool accepted = false; |
|
854 |
PlatformMouseEvent mev(ev, 0); |
|
855 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
856 |
if (mev.button() != NoButton) |
|
857 |
accepted = frame->eventHandler()->handleMouseReleaseEvent(mev); |
|
858 |
ev->setAccepted(accepted); |
|
859 |
||
860 |
handleClipboard(ev, ev->button()); |
|
861 |
handleSoftwareInputPanel(ev->button()); |
|
862 |
} |
|
863 |
||
864 |
void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button) |
|
865 |
{ |
|
866 |
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
Frame* frame = page->focusController()->focusedFrame(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
868 |
if (!frame) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
869 |
return; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
870 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
871 |
if (client && client->inputMethodEnabled() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
872 |
&& frame->document()->focusedNode() |
0 | 873 |
&& button == Qt::LeftButton && qApp->autoSipEnabled()) { |
874 |
QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); |
0 | 876 |
if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) { |
877 |
QEvent event(QEvent::RequestSoftwareInputPanel); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
878 |
QApplication::sendEvent(client->ownerWidget(), &event); |
0 | 879 |
} |
880 |
} |
|
881 |
||
882 |
clickCausedFocus = false; |
|
883 |
#endif |
|
884 |
} |
|
885 |
||
886 |
void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev) |
|
887 |
{ |
|
888 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
889 |
if (!frame->view()) |
|
890 |
return; |
|
891 |
||
892 |
bool accepted = false; |
|
893 |
PlatformMouseEvent mev(ev, 0); |
|
894 |
// ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton |
|
895 |
if (mev.button() != NoButton) |
|
896 |
accepted = frame->eventHandler()->handleMouseReleaseEvent(mev); |
|
897 |
ev->setAccepted(accepted); |
|
898 |
||
899 |
handleClipboard(ev, ev->button()); |
|
900 |
handleSoftwareInputPanel(ev->button()); |
|
901 |
} |
|
902 |
||
903 |
#ifndef QT_NO_CONTEXTMENU |
|
904 |
void QWebPagePrivate::contextMenuEvent(const QPoint& globalPos) |
|
905 |
{ |
|
906 |
QMenu *menu = q->createStandardContextMenu(); |
|
907 |
if (menu) { |
|
908 |
menu->exec(globalPos); |
|
909 |
delete menu; |
|
910 |
} |
|
911 |
} |
|
912 |
#endif // QT_NO_CONTEXTMENU |
|
913 |
||
914 |
/*! |
|
915 |
\since 4.5 |
|
916 |
This function creates the standard context menu which is shown when |
|
917 |
the user clicks on the web page with the right mouse button. It is |
|
918 |
called from the default contextMenuEvent() handler. The popup menu's |
|
919 |
ownership is transferred to the caller. |
|
920 |
*/ |
|
921 |
QMenu *QWebPage::createStandardContextMenu() |
|
922 |
{ |
|
923 |
#ifndef QT_NO_CONTEXTMENU |
|
924 |
QMenu *menu = d->currentContextMenu; |
|
925 |
d->currentContextMenu = 0; |
|
926 |
return menu; |
|
927 |
#else |
|
928 |
return 0; |
|
929 |
#endif |
|
930 |
} |
|
931 |
||
932 |
#ifndef QT_NO_WHEELEVENT |
|
933 |
void QWebPagePrivate::wheelEvent(QGraphicsSceneWheelEvent* ev) |
|
934 |
{ |
|
935 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
936 |
if (!frame->view()) |
|
937 |
return; |
|
938 |
||
939 |
WebCore::PlatformWheelEvent pev(ev); |
|
940 |
bool accepted = frame->eventHandler()->handleWheelEvent(pev); |
|
941 |
ev->setAccepted(accepted); |
|
942 |
} |
|
943 |
||
944 |
void QWebPagePrivate::wheelEvent(QWheelEvent *ev) |
|
945 |
{ |
|
946 |
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame); |
|
947 |
if (!frame->view()) |
|
948 |
return; |
|
949 |
||
950 |
WebCore::PlatformWheelEvent pev(ev); |
|
951 |
bool accepted = frame->eventHandler()->handleWheelEvent(pev); |
|
952 |
ev->setAccepted(accepted); |
|
953 |
} |
|
954 |
#endif // QT_NO_WHEELEVENT |
|
955 |
||
956 |
#ifndef QT_NO_SHORTCUT |
|
957 |
QWebPage::WebAction QWebPagePrivate::editorActionForKeyEvent(QKeyEvent* event) |
|
958 |
{ |
|
959 |
static struct { |
|
960 |
QKeySequence::StandardKey standardKey; |
|
961 |
QWebPage::WebAction action; |
|
962 |
} editorActions[] = { |
|
963 |
{ QKeySequence::Cut, QWebPage::Cut }, |
|
964 |
{ QKeySequence::Copy, QWebPage::Copy }, |
|
965 |
{ QKeySequence::Paste, QWebPage::Paste }, |
|
966 |
{ QKeySequence::Undo, QWebPage::Undo }, |
|
967 |
{ QKeySequence::Redo, QWebPage::Redo }, |
|
968 |
{ QKeySequence::MoveToNextChar, QWebPage::MoveToNextChar }, |
|
969 |
{ QKeySequence::MoveToPreviousChar, QWebPage::MoveToPreviousChar }, |
|
970 |
{ QKeySequence::MoveToNextWord, QWebPage::MoveToNextWord }, |
|
971 |
{ QKeySequence::MoveToPreviousWord, QWebPage::MoveToPreviousWord }, |
|
972 |
{ QKeySequence::MoveToNextLine, QWebPage::MoveToNextLine }, |
|
973 |
{ QKeySequence::MoveToPreviousLine, QWebPage::MoveToPreviousLine }, |
|
974 |
{ QKeySequence::MoveToStartOfLine, QWebPage::MoveToStartOfLine }, |
|
975 |
{ QKeySequence::MoveToEndOfLine, QWebPage::MoveToEndOfLine }, |
|
976 |
{ QKeySequence::MoveToStartOfBlock, QWebPage::MoveToStartOfBlock }, |
|
977 |
{ QKeySequence::MoveToEndOfBlock, QWebPage::MoveToEndOfBlock }, |
|
978 |
{ QKeySequence::MoveToStartOfDocument, QWebPage::MoveToStartOfDocument }, |
|
979 |
{ QKeySequence::MoveToEndOfDocument, QWebPage::MoveToEndOfDocument }, |
|
980 |
{ QKeySequence::SelectNextChar, QWebPage::SelectNextChar }, |
|
981 |
{ QKeySequence::SelectPreviousChar, QWebPage::SelectPreviousChar }, |
|
982 |
{ QKeySequence::SelectNextWord, QWebPage::SelectNextWord }, |
|
983 |
{ QKeySequence::SelectPreviousWord, QWebPage::SelectPreviousWord }, |
|
984 |
{ QKeySequence::SelectNextLine, QWebPage::SelectNextLine }, |
|
985 |
{ QKeySequence::SelectPreviousLine, QWebPage::SelectPreviousLine }, |
|
986 |
{ QKeySequence::SelectStartOfLine, QWebPage::SelectStartOfLine }, |
|
987 |
{ QKeySequence::SelectEndOfLine, QWebPage::SelectEndOfLine }, |
|
988 |
{ QKeySequence::SelectStartOfBlock, QWebPage::SelectStartOfBlock }, |
|
989 |
{ QKeySequence::SelectEndOfBlock, QWebPage::SelectEndOfBlock }, |
|
990 |
{ QKeySequence::SelectStartOfDocument, QWebPage::SelectStartOfDocument }, |
|
991 |
{ QKeySequence::SelectEndOfDocument, QWebPage::SelectEndOfDocument }, |
|
992 |
{ QKeySequence::DeleteStartOfWord, QWebPage::DeleteStartOfWord }, |
|
993 |
{ QKeySequence::DeleteEndOfWord, QWebPage::DeleteEndOfWord }, |
|
994 |
#if QT_VERSION >= 0x040500 |
|
995 |
{ QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator }, |
|
996 |
{ QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator }, |
|
997 |
#endif |
|
998 |
{ QKeySequence::SelectAll, QWebPage::SelectAll }, |
|
999 |
{ QKeySequence::UnknownKey, QWebPage::NoWebAction } |
|
1000 |
}; |
|
1001 |
||
1002 |
for (int i = 0; editorActions[i].standardKey != QKeySequence::UnknownKey; ++i) |
|
1003 |
if (event == editorActions[i].standardKey) |
|
1004 |
return editorActions[i].action; |
|
1005 |
||
1006 |
return QWebPage::NoWebAction; |
|
1007 |
} |
|
1008 |
#endif // QT_NO_SHORTCUT |
|
1009 |
||
1010 |
void QWebPagePrivate::keyPressEvent(QKeyEvent *ev) |
|
1011 |
{ |
|
1012 |
bool handled = false; |
|
1013 |
WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); |
|
1014 |
// we forward the key event to WebCore first to handle potential DOM |
|
1015 |
// defined event handlers and later on end up in EditorClientQt::handleKeyboardEvent |
|
1016 |
// to trigger editor commands via triggerAction(). |
|
1017 |
if (!handled) |
|
1018 |
handled = frame->eventHandler()->keyEvent(ev); |
|
1019 |
if (!handled) { |
|
1020 |
handled = true; |
|
1021 |
QFont defaultFont; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
if (q->view()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1023 |
defaultFont = q->view()->font(); |
0 | 1024 |
QFontMetrics fm(defaultFont); |
1025 |
if (!handleScrolling(ev, frame)) { |
|
1026 |
switch (ev->key()) { |
|
1027 |
case Qt::Key_Back: |
|
1028 |
q->triggerAction(QWebPage::Back); |
|
1029 |
break; |
|
1030 |
case Qt::Key_Forward: |
|
1031 |
q->triggerAction(QWebPage::Forward); |
|
1032 |
break; |
|
1033 |
case Qt::Key_Stop: |
|
1034 |
q->triggerAction(QWebPage::Stop); |
|
1035 |
break; |
|
1036 |
case Qt::Key_Refresh: |
|
1037 |
q->triggerAction(QWebPage::Reload); |
|
1038 |
break; |
|
1039 |
case Qt::Key_Backspace: |
|
1040 |
if (ev->modifiers() == Qt::ShiftModifier) |
|
1041 |
q->triggerAction(QWebPage::Forward); |
|
1042 |
else |
|
1043 |
q->triggerAction(QWebPage::Back); |
|
1044 |
break; |
|
1045 |
default: |
|
1046 |
handled = false; |
|
1047 |
break; |
|
1048 |
} |
|
1049 |
} |
|
1050 |
} |
|
1051 |
||
1052 |
ev->setAccepted(handled); |
|
1053 |
} |
|
1054 |
||
1055 |
void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev) |
|
1056 |
{ |
|
1057 |
if (ev->isAutoRepeat()) { |
|
1058 |
ev->setAccepted(true); |
|
1059 |
return; |
|
1060 |
} |
|
1061 |
||
1062 |
WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); |
|
1063 |
bool handled = frame->eventHandler()->keyEvent(ev); |
|
1064 |
ev->setAccepted(handled); |
|
1065 |
} |
|
1066 |
||
1067 |
void QWebPagePrivate::focusInEvent(QFocusEvent*) |
|
1068 |
{ |
|
1069 |
FocusController *focusController = page->focusController(); |
|
1070 |
focusController->setActive(true); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1071 |
focusController->setFocused(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1072 |
if (!focusController->focusedFrame()) |
0 | 1073 |
focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame)); |
1074 |
} |
|
1075 |
||
1076 |
void QWebPagePrivate::focusOutEvent(QFocusEvent*) |
|
1077 |
{ |
|
1078 |
// only set the focused frame inactive so that we stop painting the caret |
|
1079 |
// and the focus frame. But don't tell the focus controller so that upon |
|
1080 |
// focusInEvent() we can re-activate the frame. |
|
1081 |
FocusController *focusController = page->focusController(); |
|
1082 |
focusController->setActive(false); |
|
1083 |
focusController->setFocused(false); |
|
1084 |
} |
|
1085 |
||
1086 |
void QWebPagePrivate::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) |
|
1087 |
{ |
|
1088 |
#ifndef QT_NO_DRAGANDDROP |
|
1089 |
DragData dragData(ev->mimeData(), ev->pos().toPoint(), |
|
1090 |
QCursor::pos(), dropActionToDragOp(ev->possibleActions())); |
|
1091 |
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData)); |
|
1092 |
ev->setDropAction(action); |
|
1093 |
if (action != Qt::IgnoreAction) |
|
1094 |
ev->accept(); |
|
1095 |
#endif |
|
1096 |
} |
|
1097 |
||
1098 |
void QWebPagePrivate::dragEnterEvent(QDragEnterEvent* ev) |
|
1099 |
{ |
|
1100 |
#ifndef QT_NO_DRAGANDDROP |
|
1101 |
DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(), |
|
1102 |
dropActionToDragOp(ev->possibleActions())); |
|
1103 |
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData)); |
|
1104 |
ev->setDropAction(action); |
|
1105 |
if (action != Qt::IgnoreAction) |
|
1106 |
ev->accept(); |
|
1107 |
#endif |
|
1108 |
} |
|
1109 |
||
1110 |
void QWebPagePrivate::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) |
|
1111 |
{ |
|
1112 |
#ifndef QT_NO_DRAGANDDROP |
|
1113 |
DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone); |
|
1114 |
page->dragController()->dragExited(&dragData); |
|
1115 |
ev->accept(); |
|
1116 |
#endif |
|
1117 |
} |
|
1118 |
||
1119 |
void QWebPagePrivate::dragLeaveEvent(QDragLeaveEvent* ev) |
|
1120 |
{ |
|
1121 |
#ifndef QT_NO_DRAGANDDROP |
|
1122 |
DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone); |
|
1123 |
page->dragController()->dragExited(&dragData); |
|
1124 |
ev->accept(); |
|
1125 |
#endif |
|
1126 |
} |
|
1127 |
||
1128 |
void QWebPagePrivate::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) |
|
1129 |
{ |
|
1130 |
#ifndef QT_NO_DRAGANDDROP |
|
1131 |
DragData dragData(ev->mimeData(), ev->pos().toPoint(), |
|
1132 |
QCursor::pos(), dropActionToDragOp(ev->possibleActions())); |
|
1133 |
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragUpdated(&dragData)); |
|
1134 |
ev->setDropAction(action); |
|
1135 |
if (action != Qt::IgnoreAction) |
|
1136 |
ev->accept(); |
|
1137 |
#endif |
|
1138 |
} |
|
1139 |
||
1140 |
void QWebPagePrivate::dragMoveEvent(QDragMoveEvent* ev) |
|
1141 |
{ |
|
1142 |
#ifndef QT_NO_DRAGANDDROP |
|
1143 |
DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(), |
|
1144 |
dropActionToDragOp(ev->possibleActions())); |
|
1145 |
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragUpdated(&dragData)); |
|
1146 |
ev->setDropAction(action); |
|
1147 |
if (action != Qt::IgnoreAction) |
|
1148 |
ev->accept(); |
|
1149 |
#endif |
|
1150 |
} |
|
1151 |
||
1152 |
void QWebPagePrivate::dropEvent(QGraphicsSceneDragDropEvent* ev) |
|
1153 |
{ |
|
1154 |
#ifndef QT_NO_DRAGANDDROP |
|
1155 |
DragData dragData(ev->mimeData(), ev->pos().toPoint(), |
|
1156 |
QCursor::pos(), dropActionToDragOp(ev->possibleActions())); |
|
1157 |
Qt::DropAction action = dragOpToDropAction(page->dragController()->performDrag(&dragData)); |
|
1158 |
if (action != Qt::IgnoreAction) |
|
1159 |
ev->accept(); |
|
1160 |
#endif |
|
1161 |
} |
|
1162 |
||
1163 |
void QWebPagePrivate::dropEvent(QDropEvent* ev) |
|
1164 |
{ |
|
1165 |
#ifndef QT_NO_DRAGANDDROP |
|
1166 |
DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(), |
|
1167 |
dropActionToDragOp(ev->possibleActions())); |
|
1168 |
Qt::DropAction action = dragOpToDropAction(page->dragController()->performDrag(&dragData)); |
|
1169 |
if (action != Qt::IgnoreAction) |
|
1170 |
ev->accept(); |
|
1171 |
#endif |
|
1172 |
} |
|
1173 |
||
1174 |
void QWebPagePrivate::leaveEvent(QEvent*) |
|
1175 |
{ |
|
1176 |
// Fake a mouse move event just outside of the widget, since all |
|
1177 |
// the interesting mouse-out behavior like invalidating scrollbars |
|
1178 |
// is handled by the WebKit event handler's mouseMoved function. |
|
1179 |
QMouseEvent fakeEvent(QEvent::MouseMove, QCursor::pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); |
|
1180 |
mouseMoveEvent(&fakeEvent); |
|
1181 |
} |
|
1182 |
||
1183 |
/*! |
|
1184 |
\property QWebPage::palette |
|
1185 |
\brief the page's palette |
|
1186 |
||
1187 |
The base brush of the palette is used to draw the background of the main frame. |
|
1188 |
||
1189 |
By default, this property contains the application's default palette. |
|
1190 |
*/ |
|
1191 |
void QWebPage::setPalette(const QPalette &pal) |
|
1192 |
{ |
|
1193 |
d->palette = pal; |
|
1194 |
if (!d->mainFrame || !d->mainFrame->d->frame->view()) |
|
1195 |
return; |
|
1196 |
||
1197 |
QBrush brush = pal.brush(QPalette::Base); |
|
1198 |
QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor(); |
|
1199 |
QWebFramePrivate::core(d->mainFrame)->view()->updateBackgroundRecursively(backgroundColor, !backgroundColor.alpha()); |
|
1200 |
} |
|
1201 |
||
1202 |
QPalette QWebPage::palette() const |
|
1203 |
{ |
|
1204 |
return d->palette; |
|
1205 |
} |
|
1206 |
||
1207 |
void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) |
|
1208 |
{ |
|
1209 |
WebCore::Frame *frame = page->focusController()->focusedOrMainFrame(); |
|
1210 |
WebCore::Editor *editor = frame->editor(); |
|
1211 |
||
1212 |
if (!editor->canEdit()) { |
|
1213 |
ev->ignore(); |
|
1214 |
return; |
|
1215 |
} |
|
1216 |
||
1217 |
RenderObject* renderer = 0; |
|
1218 |
RenderTextControl* renderTextControl = 0; |
|
1219 |
||
1220 |
if (frame->selection()->rootEditableElement()) |
|
1221 |
renderer = frame->selection()->rootEditableElement()->shadowAncestorNode()->renderer(); |
|
1222 |
||
1223 |
if (renderer && renderer->isTextControl()) |
|
1224 |
renderTextControl = toRenderTextControl(renderer); |
|
1225 |
||
1226 |
Vector<CompositionUnderline> underlines; |
|
1227 |
||
1228 |
for (int i = 0; i < ev->attributes().size(); ++i) { |
|
1229 |
const QInputMethodEvent::Attribute& a = ev->attributes().at(i); |
|
1230 |
switch (a.type) { |
|
1231 |
case QInputMethodEvent::TextFormat: { |
|
1232 |
QTextCharFormat textCharFormat = a.value.value<QTextFormat>().toCharFormat(); |
|
1233 |
QColor qcolor = textCharFormat.underlineColor(); |
|
1234 |
underlines.append(CompositionUnderline(a.start, a.length, Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())), false)); |
|
1235 |
break; |
|
1236 |
} |
|
1237 |
case QInputMethodEvent::Cursor: { |
|
1238 |
frame->setCaretVisible(a.length); //if length is 0 cursor is invisible |
|
1239 |
if (a.length > 0) { |
|
1240 |
RenderObject* caretRenderer = frame->selection()->caretRenderer(); |
|
1241 |
if (caretRenderer) { |
|
1242 |
QColor qcolor = a.value.value<QColor>(); |
|
1243 |
caretRenderer->style()->setColor(Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha()))); |
|
1244 |
} |
|
1245 |
} |
|
1246 |
break; |
|
1247 |
} |
|
1248 |
#if QT_VERSION >= 0x040600 |
|
1249 |
case QInputMethodEvent::Selection: { |
|
1250 |
if (renderTextControl) { |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1251 |
renderTextControl->setSelectionStart(qMin(a.start, (a.start + a.length))); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1252 |
renderTextControl->setSelectionEnd(qMax(a.start, (a.start + a.length))); |
0 | 1253 |
} |
1254 |
break; |
|
1255 |
} |
|
1256 |
#endif |
|
1257 |
} |
|
1258 |
} |
|
1259 |
||
1260 |
if (!ev->commitString().isEmpty()) |
|
1261 |
editor->confirmComposition(ev->commitString()); |
|
1262 |
else if (!ev->preeditString().isEmpty()) { |
|
1263 |
QString preedit = ev->preeditString(); |
|
1264 |
editor->setComposition(preedit, underlines, preedit.length(), 0); |
|
1265 |
} |
|
1266 |
ev->accept(); |
|
1267 |
} |
|
1268 |
||
1269 |
void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event) |
|
1270 |
{ |
|
1271 |
WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); |
|
1272 |
WebCore::Editor* editor = frame->editor(); |
|
1273 |
if (editor->canEdit()) { |
|
1274 |
if (event->modifiers() == Qt::NoModifier |
|
1275 |
|| event->modifiers() == Qt::ShiftModifier |
|
1276 |
|| event->modifiers() == Qt::KeypadModifier) { |
|
1277 |
if (event->key() < Qt::Key_Escape) { |
|
1278 |
event->accept(); |
|
1279 |
} else { |
|
1280 |
switch (event->key()) { |
|
1281 |
case Qt::Key_Return: |
|
1282 |
case Qt::Key_Enter: |
|
1283 |
case Qt::Key_Delete: |
|
1284 |
case Qt::Key_Home: |
|
1285 |
case Qt::Key_End: |
|
1286 |
case Qt::Key_Backspace: |
|
1287 |
case Qt::Key_Left: |
|
1288 |
case Qt::Key_Right: |
|
1289 |
case Qt::Key_Up: |
|
1290 |
case Qt::Key_Down: |
|
1291 |
case Qt::Key_Tab: |
|
1292 |
event->accept(); |
|
1293 |
default: |
|
1294 |
break; |
|
1295 |
} |
|
1296 |
} |
|
1297 |
} |
|
1298 |
#ifndef QT_NO_SHORTCUT |
|
1299 |
else if (editorActionForKeyEvent(event) != QWebPage::NoWebAction) |
|
1300 |
event->accept(); |
|
1301 |
#endif |
|
1302 |
} |
|
1303 |
} |
|
1304 |
||
1305 |
bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame) |
|
1306 |
{ |
|
1307 |
ScrollDirection direction; |
|
1308 |
ScrollGranularity granularity; |
|
1309 |
||
1310 |
#ifndef QT_NO_SHORTCUT |
|
1311 |
if (ev == QKeySequence::MoveToNextPage |
|
1312 |
|| (ev->key() == Qt::Key_Space && !(ev->modifiers() & Qt::ShiftModifier))) { |
|
1313 |
granularity = ScrollByPage; |
|
1314 |
direction = ScrollDown; |
|
1315 |
} else if (ev == QKeySequence::MoveToPreviousPage |
|
1316 |
|| (ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier)) { |
|
1317 |
granularity = ScrollByPage; |
|
1318 |
direction = ScrollUp; |
|
1319 |
} else |
|
1320 |
#endif // QT_NO_SHORTCUT |
|
1321 |
if (ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier |
|
1322 |
|| ev->key() == Qt::Key_Home) { |
|
1323 |
granularity = ScrollByDocument; |
|
1324 |
direction = ScrollUp; |
|
1325 |
} else if (ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier |
|
1326 |
|| ev->key() == Qt::Key_End) { |
|
1327 |
granularity = ScrollByDocument; |
|
1328 |
direction = ScrollDown; |
|
1329 |
} else { |
|
1330 |
switch (ev->key()) { |
|
1331 |
case Qt::Key_Up: |
|
1332 |
granularity = ScrollByLine; |
|
1333 |
direction = ScrollUp; |
|
1334 |
break; |
|
1335 |
case Qt::Key_Down: |
|
1336 |
granularity = ScrollByLine; |
|
1337 |
direction = ScrollDown; |
|
1338 |
break; |
|
1339 |
case Qt::Key_Left: |
|
1340 |
granularity = ScrollByLine; |
|
1341 |
direction = ScrollLeft; |
|
1342 |
break; |
|
1343 |
case Qt::Key_Right: |
|
1344 |
granularity = ScrollByLine; |
|
1345 |
direction = ScrollRight; |
|
1346 |
break; |
|
1347 |
default: |
|
1348 |
return false; |
|
1349 |
} |
|
1350 |
} |
|
1351 |
||
1352 |
return frame->eventHandler()->scrollRecursively(direction, granularity); |
|
1353 |
} |
|
1354 |
||
1355 |
/*! |
|
1356 |
This method is used by the input method to query a set of properties of the page |
|
1357 |
to be able to support complex input method operations as support for surrounding |
|
1358 |
text and reconversions. |
|
1359 |
||
1360 |
\a property specifies which property is queried. |
|
1361 |
||
1362 |
\sa QWidget::inputMethodEvent(), QInputMethodEvent, QInputContext |
|
1363 |
*/ |
|
1364 |
QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const |
|
1365 |
{ |
|
1366 |
Frame* frame = d->page->focusController()->focusedFrame(); |
|
1367 |
if (!frame) |
|
1368 |
return QVariant(); |
|
1369 |
||
1370 |
WebCore::Editor* editor = frame->editor(); |
|
1371 |
||
1372 |
RenderObject* renderer = 0; |
|
1373 |
RenderTextControl* renderTextControl = 0; |
|
1374 |
||
1375 |
if (frame->selection()->rootEditableElement()) |
|
1376 |
renderer = frame->selection()->rootEditableElement()->shadowAncestorNode()->renderer(); |
|
1377 |
||
1378 |
if (renderer && renderer->isTextControl()) |
|
1379 |
renderTextControl = toRenderTextControl(renderer); |
|
1380 |
||
1381 |
switch (property) { |
|
1382 |
case Qt::ImMicroFocus: { |
|
1383 |
return QVariant(frame->selection()->absoluteCaretBounds()); |
|
1384 |
} |
|
1385 |
case Qt::ImFont: { |
|
1386 |
if (renderTextControl) { |
|
1387 |
RenderStyle* renderStyle = renderTextControl->style(); |
|
1388 |
return QVariant(QFont(renderStyle->font().font())); |
|
1389 |
} |
|
1390 |
return QVariant(QFont()); |
|
1391 |
} |
|
1392 |
case Qt::ImCursorPosition: { |
|
1393 |
if (renderTextControl) { |
|
1394 |
if (editor->hasComposition()) { |
|
1395 |
RefPtr<Range> range = editor->compositionRange(); |
|
1396 |
return QVariant(renderTextControl->selectionEnd() - TextIterator::rangeLength(range.get())); |
|
1397 |
} |
|
1398 |
return QVariant(renderTextControl->selectionEnd()); |
|
1399 |
} |
|
1400 |
return QVariant(); |
|
1401 |
} |
|
1402 |
case Qt::ImSurroundingText: { |
|
1403 |
if (renderTextControl) { |
|
1404 |
QString text = renderTextControl->text(); |
|
1405 |
RefPtr<Range> range = editor->compositionRange(); |
|
1406 |
if (range) { |
|
1407 |
text.remove(range->startPosition().offsetInContainerNode(), TextIterator::rangeLength(range.get())); |
|
1408 |
} |
|
1409 |
return QVariant(text); |
|
1410 |
} |
|
1411 |
return QVariant(); |
|
1412 |
} |
|
1413 |
case Qt::ImCurrentSelection: { |
|
1414 |
if (renderTextControl) { |
|
1415 |
int start = renderTextControl->selectionStart(); |
|
1416 |
int end = renderTextControl->selectionEnd(); |
|
1417 |
if (end > start) |
|
1418 |
return QVariant(QString(renderTextControl->text()).mid(start,end-start)); |
|
1419 |
} |
|
1420 |
return QVariant(); |
|
1421 |
||
1422 |
} |
|
1423 |
#if QT_VERSION >= 0x040600 |
|
1424 |
case Qt::ImAnchorPosition: { |
|
1425 |
if (renderTextControl) { |
|
1426 |
if (editor->hasComposition()) { |
|
1427 |
RefPtr<Range> range = editor->compositionRange(); |
|
1428 |
return QVariant(renderTextControl->selectionStart() - TextIterator::rangeLength(range.get())); |
|
1429 |
} |
|
1430 |
return QVariant(renderTextControl->selectionStart()); |
|
1431 |
} |
|
1432 |
return QVariant(); |
|
1433 |
} |
|
1434 |
case Qt::ImMaximumTextLength: { |
|
1435 |
if (frame->selection()->isContentEditable()) { |
|
1436 |
if (frame->document() && frame->document()->focusedNode()) { |
|
1437 |
if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) { |
|
1438 |
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode()); |
|
1439 |
return QVariant(inputElement->maxLength()); |
|
1440 |
} |
|
1441 |
} |
|
1442 |
return QVariant(InputElement::s_maximumLength); |
|
1443 |
} |
|
1444 |
return QVariant(0); |
|
1445 |
} |
|
1446 |
#endif |
|
1447 |
default: |
|
1448 |
return QVariant(); |
|
1449 |
} |
|
1450 |
} |
|
1451 |
||
1452 |
/*! |
|
1453 |
\internal |
|
1454 |
*/ |
|
1455 |
void QWebPagePrivate::setInspector(QWebInspector* insp) |
|
1456 |
{ |
|
1457 |
if (inspector) |
|
1458 |
inspector->d->setFrontend(0); |
|
1459 |
||
1460 |
if (inspectorIsInternalOnly) { |
|
1461 |
QWebInspector* inspToDelete = inspector; |
|
1462 |
inspector = 0; |
|
1463 |
inspectorIsInternalOnly = false; |
|
1464 |
delete inspToDelete; // Delete after to prevent infinite recursion |
|
1465 |
} |
|
1466 |
||
1467 |
inspector = insp; |
|
1468 |
||
1469 |
// Give inspector frontend web view if previously created |
|
1470 |
if (inspector && inspectorFrontend) |
|
1471 |
inspector->d->setFrontend(inspectorFrontend); |
|
1472 |
} |
|
1473 |
||
1474 |
/*! |
|
1475 |
\internal |
|
1476 |
Returns the inspector and creates it if it wasn't created yet. |
|
1477 |
The instance created here will not be available through QWebPage's API. |
|
1478 |
*/ |
|
1479 |
QWebInspector* QWebPagePrivate::getOrCreateInspector() |
|
1480 |
{ |
|
1481 |
if (!inspector) { |
|
1482 |
QWebInspector* insp = new QWebInspector; |
|
1483 |
insp->setPage(q); |
|
1484 |
inspectorIsInternalOnly = true; |
|
1485 |
||
1486 |
Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q) |
|
1487 |
} |
|
1488 |
return inspector; |
|
1489 |
} |
|
1490 |
||
1491 |
/*! \internal */ |
|
1492 |
InspectorController* QWebPagePrivate::inspectorController() |
|
1493 |
{ |
|
1494 |
return page->inspectorController(); |
|
1495 |
} |
|
1496 |
||
1497 |
||
1498 |
/*! |
|
1499 |
\enum QWebPage::FindFlag |
|
1500 |
||
1501 |
This enum describes the options available to QWebPage's findText() function. The options |
|
1502 |
can be OR-ed together from the following list: |
|
1503 |
||
1504 |
\value FindBackward Searches backwards instead of forwards. |
|
1505 |
\value FindCaseSensitively By default findText() works case insensitive. Specifying this option |
|
1506 |
changes the behaviour to a case sensitive find operation. |
|
1507 |
\value FindWrapsAroundDocument Makes findText() restart from the beginning of the document if the end |
|
1508 |
was reached and the text was not found. |
|
1509 |
\value HighlightAllOccurrences Highlights all existing occurrences of a specific string. |
|
1510 |
*/ |
|
1511 |
||
1512 |
/*! |
|
1513 |
\enum QWebPage::LinkDelegationPolicy |
|
1514 |
||
1515 |
This enum defines the delegation policies a webpage can have when activating links and emitting |
|
1516 |
the linkClicked() signal. |
|
1517 |
||
1518 |
\value DontDelegateLinks No links are delegated. Instead, QWebPage tries to handle them all. |
|
1519 |
\value DelegateExternalLinks When activating links that point to documents not stored on the |
|
1520 |
local filesystem or an equivalent - such as the Qt resource system - then linkClicked() is emitted. |
|
1521 |
\value DelegateAllLinks Whenever a link is activated the linkClicked() signal is emitted. |
|
1522 |
*/ |
|
1523 |
||
1524 |
/*! |
|
1525 |
\enum QWebPage::NavigationType |
|
1526 |
||
1527 |
This enum describes the types of navigation available when browsing through hyperlinked |
|
1528 |
documents. |
|
1529 |
||
1530 |
\value NavigationTypeLinkClicked The user clicked on a link or pressed return on a focused link. |
|
1531 |
\value NavigationTypeFormSubmitted The user activated a submit button for an HTML form. |
|
1532 |
\value NavigationTypeBackOrForward Navigation to a previously shown document in the back or forward history is requested. |
|
1533 |
\value NavigationTypeReload The user activated the reload action. |
|
1534 |
\value NavigationTypeFormResubmitted An HTML form was submitted a second time. |
|
1535 |
\value NavigationTypeOther A navigation to another document using a method not listed above. |
|
1536 |
*/ |
|
1537 |
||
1538 |
/*! |
|
1539 |
\enum QWebPage::WebAction |
|
1540 |
||
1541 |
This enum describes the types of action which can be performed on the web page. |
|
1542 |
||
1543 |
Actions only have an effect when they are applicable. The availability of |
|
1544 |
actions can be be determined by checking \l{QAction::}{isEnabled()} on the |
|
1545 |
action returned by \l{QWebPage::}{action()}. |
|
1546 |
||
1547 |
One method of enabling the text editing, cursor movement, and text selection actions |
|
1548 |
is by setting \l contentEditable to true. |
|
1549 |
||
1550 |
\value NoWebAction No action is triggered. |
|
1551 |
\value OpenLink Open the current link. |
|
1552 |
\value OpenLinkInNewWindow Open the current link in a new window. |
|
1553 |
\value OpenFrameInNewWindow Replicate the current frame in a new window. |
|
1554 |
\value DownloadLinkToDisk Download the current link to the disk. |
|
1555 |
\value CopyLinkToClipboard Copy the current link to the clipboard. |
|
1556 |
\value OpenImageInNewWindow Open the highlighted image in a new window. |
|
1557 |
\value DownloadImageToDisk Download the highlighted image to the disk. |
|
1558 |
\value CopyImageToClipboard Copy the highlighted image to the clipboard. |
|
1559 |
\value Back Navigate back in the history of navigated links. |
|
1560 |
\value Forward Navigate forward in the history of navigated links. |
|
1561 |
\value Stop Stop loading the current page. |
|
1562 |
\value Reload Reload the current page. |
|
1563 |
\value ReloadAndBypassCache Reload the current page, but do not use any local cache. (Added in Qt 4.6) |
|
1564 |
\value Cut Cut the content currently selected into the clipboard. |
|
1565 |
\value Copy Copy the content currently selected into the clipboard. |
|
1566 |
\value Paste Paste content from the clipboard. |
|
1567 |
\value Undo Undo the last editing action. |
|
1568 |
\value Redo Redo the last editing action. |
|
1569 |
\value MoveToNextChar Move the cursor to the next character. |
|
1570 |
\value MoveToPreviousChar Move the cursor to the previous character. |
|
1571 |
\value MoveToNextWord Move the cursor to the next word. |
|
1572 |
\value MoveToPreviousWord Move the cursor to the previous word. |
|
1573 |
\value MoveToNextLine Move the cursor to the next line. |
|
1574 |
\value MoveToPreviousLine Move the cursor to the previous line. |
|
1575 |
\value MoveToStartOfLine Move the cursor to the start of the line. |
|
1576 |
\value MoveToEndOfLine Move the cursor to the end of the line. |
|
1577 |
\value MoveToStartOfBlock Move the cursor to the start of the block. |
|
1578 |
\value MoveToEndOfBlock Move the cursor to the end of the block. |
|
1579 |
\value MoveToStartOfDocument Move the cursor to the start of the document. |
|
1580 |
\value MoveToEndOfDocument Move the cursor to the end of the document. |
|
1581 |
\value SelectNextChar Select to the next character. |
|
1582 |
\value SelectPreviousChar Select to the previous character. |
|
1583 |
\value SelectNextWord Select to the next word. |
|
1584 |
\value SelectPreviousWord Select to the previous word. |
|
1585 |
\value SelectNextLine Select to the next line. |
|
1586 |
\value SelectPreviousLine Select to the previous line. |
|
1587 |
\value SelectStartOfLine Select to the start of the line. |
|
1588 |
\value SelectEndOfLine Select to the end of the line. |
|
1589 |
\value SelectStartOfBlock Select to the start of the block. |
|
1590 |
\value SelectEndOfBlock Select to the end of the block. |
|
1591 |
\value SelectStartOfDocument Select to the start of the document. |
|
1592 |
\value SelectEndOfDocument Select to the end of the document. |
|
1593 |
\value DeleteStartOfWord Delete to the start of the word. |
|
1594 |
\value DeleteEndOfWord Delete to the end of the word. |
|
1595 |
\value SetTextDirectionDefault Set the text direction to the default direction. |
|
1596 |
\value SetTextDirectionLeftToRight Set the text direction to left-to-right. |
|
1597 |
\value SetTextDirectionRightToLeft Set the text direction to right-to-left. |
|
1598 |
\value ToggleBold Toggle the formatting between bold and normal weight. |
|
1599 |
\value ToggleItalic Toggle the formatting between italic and normal style. |
|
1600 |
\value ToggleUnderline Toggle underlining. |
|
1601 |
\value InspectElement Show the Web Inspector with the currently highlighted HTML element. |
|
1602 |
\value InsertParagraphSeparator Insert a new paragraph. |
|
1603 |
\value InsertLineSeparator Insert a new line. |
|
1604 |
\value SelectAll Selects all content. |
|
1605 |
\value PasteAndMatchStyle Paste content from the clipboard with current style. |
|
1606 |
\value RemoveFormat Removes formatting and style. |
|
1607 |
\value ToggleStrikethrough Toggle the formatting between strikethrough and normal style. |
|
1608 |
\value ToggleSubscript Toggle the formatting between subscript and baseline. |
|
1609 |
\value ToggleSuperscript Toggle the formatting between supercript and baseline. |
|
1610 |
\value InsertUnorderedList Toggles the selection between an ordered list and a normal block. |
|
1611 |
\value InsertOrderedList Toggles the selection between an ordered list and a normal block. |
|
1612 |
\value Indent Increases the indentation of the currently selected format block by one increment. |
|
1613 |
\value Outdent Decreases the indentation of the currently selected format block by one increment. |
|
1614 |
\value AlignCenter Applies center alignment to content. |
|
1615 |
\value AlignJustified Applies full justification to content. |
|
1616 |
\value AlignLeft Applies left justification to content. |
|
1617 |
\value AlignRight Applies right justification to content. |
|
1618 |
||
1619 |
||
1620 |
\omitvalue WebActionCount |
|
1621 |
||
1622 |
*/ |
|
1623 |
||
1624 |
/*! |
|
1625 |
\enum QWebPage::WebWindowType |
|
1626 |
||
1627 |
\value WebBrowserWindow The window is a regular web browser window. |
|
1628 |
\value WebModalDialog The window acts as modal dialog. |
|
1629 |
*/ |
|
1630 |
||
1631 |
/*! |
|
1632 |
\class QWebPage |
|
1633 |
\since 4.4 |
|
1634 |
\brief The QWebPage class provides an object to view and edit web documents. |
|
1635 |
||
1636 |
\inmodule QtWebKit |
|
1637 |
||
1638 |
QWebPage holds a main frame responsible for web content, settings, the history |
|
1639 |
of navigated links and actions. This class can be used, together with QWebFrame, |
|
1640 |
to provide functionality like QWebView in a widget-less environment. |
|
1641 |
||
1642 |
QWebPage's API is very similar to QWebView, as you are still provided with |
|
1643 |
common functions like action() (known as \l{QWebView::}{pageAction()} in |
|
1644 |
QWebView), triggerAction(), findText() and settings(). More QWebView-like |
|
1645 |
functions can be found in the main frame of QWebPage, obtained via |
|
1646 |
QWebPage::mainFrame(). For example, the load(), setUrl() and setHtml() |
|
1647 |
unctions for QWebPage can be accessed using QWebFrame. |
|
1648 |
||
1649 |
The loadStarted() signal is emitted when the page begins to load.The |
|
1650 |
loadProgress() signal, on the other hand, is emitted whenever an element |
|
1651 |
of the web page completes loading, such as an embedded image, a script, |
|
1652 |
etc. Finally, the loadFinished() signal is emitted when the page has |
|
1653 |
loaded completely. Its argument, either true or false, indicates whether |
|
1654 |
or not the load operation succeeded. |
|
1655 |
||
1656 |
\section1 Using QWebPage in a Widget-less Environment |
|
1657 |
||
1658 |
Before you begin painting a QWebPage object, you need to set the size of |
|
1659 |
the viewport by calling setViewportSize(). Then, you invoke the main |
|
1660 |
frame's render function (QWebFrame::render()). An example of this |
|
1661 |
is shown in the code snippet below. |
|
1662 |
||
1663 |
Suppose we have a \c Thumbnail class as follows: |
|
1664 |
||
1665 |
\snippet webkitsnippets/webpage/main.cpp 0 |
|
1666 |
||
1667 |
The \c Thumbnail's constructor takes in a \a url. We connect our QWebPage |
|
1668 |
object's \l{QWebPage::}{loadFinished()} signal to our private slot, |
|
1669 |
\c render(). |
|
1670 |
||
1671 |
\snippet webkitsnippets/webpage/main.cpp 1 |
|
1672 |
||
1673 |
The \c render() function shows how we can paint a thumbnail using a |
|
1674 |
QWebPage object. |
|
1675 |
||
1676 |
\snippet webkitsnippets/webpage/main.cpp 2 |
|
1677 |
||
1678 |
We begin by setting the \l{QWebPage::viewportSize()}{viewportSize} and |
|
1679 |
then we instantiate a QImage object, \c image, with the same size as our |
|
1680 |
\l{QWebPage::viewportSize()}{viewportSize}. This image is then sent |
|
1681 |
as a parameter to \c painter. Next, we render the contents of the main |
|
1682 |
frame and its subframes into \c painter. Finally, we save the scaled image. |
|
1683 |
||
1684 |
\sa QWebFrame |
|
1685 |
*/ |
|
1686 |
||
1687 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1688 |
Constructs an empty QWebPage with parent \a parent. |
0 | 1689 |
*/ |
1690 |
QWebPage::QWebPage(QObject *parent) |
|
1691 |
: QObject(parent) |
|
1692 |
, d(new QWebPagePrivate(this)) |
|
1693 |
{ |
|
1694 |
setView(qobject_cast<QWidget *>(parent)); |
|
1695 |
||
1696 |
connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int))); |
|
1697 |
#ifndef NDEBUG |
|
1698 |
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(_q_cleanupLeakMessages())); |
|
1699 |
#endif |
|
1700 |
} |
|
1701 |
||
1702 |
/*! |
|
1703 |
Destroys the web page. |
|
1704 |
*/ |
|
1705 |
QWebPage::~QWebPage() |
|
1706 |
{ |
|
1707 |
d->createMainFrame(); |
|
1708 |
FrameLoader *loader = d->mainFrame->d->frame->loader(); |
|
1709 |
if (loader) |
|
1710 |
loader->detachFromParent(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1711 |
if (d->inspector) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1712 |
// Since we have to delete an internal inspector, |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1713 |
// call setInspector(0) directly to prevent potential crashes |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1714 |
if (d->inspectorIsInternalOnly) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1715 |
d->setInspector(0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1716 |
else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1717 |
d->inspector->setPage(0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1718 |
} |
0 | 1719 |
delete d; |
1720 |
} |
|
1721 |
||
1722 |
/*! |
|
1723 |
Returns the main frame of the page. |
|
1724 |
||
1725 |
The main frame provides access to the hierarchy of sub-frames and is also needed if you |
|
1726 |
want to explicitly render a web page into a given painter. |
|
1727 |
||
1728 |
\sa currentFrame() |
|
1729 |
*/ |
|
1730 |
QWebFrame *QWebPage::mainFrame() const |
|
1731 |
{ |
|
1732 |
d->createMainFrame(); |
|
1733 |
return d->mainFrame; |
|
1734 |
} |
|
1735 |
||
1736 |
/*! |
|
1737 |
Returns the frame currently active. |
|
1738 |
||
1739 |
\sa mainFrame(), frameCreated() |
|
1740 |
*/ |
|
1741 |
QWebFrame *QWebPage::currentFrame() const |
|
1742 |
{ |
|
1743 |
d->createMainFrame(); |
|
1744 |
return static_cast<WebCore::FrameLoaderClientQt *>(d->page->focusController()->focusedOrMainFrame()->loader()->client())->webFrame(); |
|
1745 |
} |
|
1746 |
||
1747 |
||
1748 |
/*! |
|
1749 |
\since 4.6 |
|
1750 |
||
1751 |
Returns the frame at the given point \a pos. |
|
1752 |
||
1753 |
\sa mainFrame(), currentFrame() |
|
1754 |
*/ |
|
1755 |
QWebFrame* QWebPage::frameAt(const QPoint& pos) const |
|
1756 |
{ |
|
1757 |
QWebFrame* webFrame = mainFrame(); |
|
1758 |
if (!webFrame->geometry().contains(pos)) |
|
1759 |
return 0; |
|
1760 |
QWebHitTestResult hitTestResult = webFrame->hitTestContent(pos); |
|
1761 |
return hitTestResult.frame(); |
|
1762 |
} |
|
1763 |
||
1764 |
/*! |
|
1765 |
Returns a pointer to the view's history of navigated web pages. |
|
1766 |
*/ |
|
1767 |
QWebHistory *QWebPage::history() const |
|
1768 |
{ |
|
1769 |
d->createMainFrame(); |
|
1770 |
return &d->history; |
|
1771 |
} |
|
1772 |
||
1773 |
/*! |
|
1774 |
Sets the \a view that is associated with the web page. |
|
1775 |
||
1776 |
\sa view() |
|
1777 |
*/ |
|
1778 |
void QWebPage::setView(QWidget *view) |
|
1779 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1780 |
if (this->view() != view) { |
0 | 1781 |
d->view = view; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1782 |
if (!view) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1783 |
delete d->client; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1784 |
d->client = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1785 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1786 |
if (!d->client) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1787 |
d->client = new QWebPageWidgetClient(view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1788 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1789 |
static_cast<QWebPageWidgetClient*>(d->client)->view = view; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1790 |
} |
0 | 1791 |
setViewportSize(view ? view->size() : QSize(0, 0)); |
1792 |
} |
|
1793 |
} |
|
1794 |
||
1795 |
/*! |
|
1796 |
Returns the view widget that is associated with the web page. |
|
1797 |
||
1798 |
\sa setView() |
|
1799 |
*/ |
|
1800 |
QWidget *QWebPage::view() const |
|
1801 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1802 |
#if QT_VERSION < 0x040600 |
0 | 1803 |
return d->view; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1804 |
#else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1805 |
return d->view.data(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1806 |
#endif |
0 | 1807 |
} |
1808 |
||
1809 |
/*! |
|
1810 |
This function is called whenever a JavaScript program tries to print a \a message to the web browser's console. |
|
1811 |
||
1812 |
For example in case of evaluation errors the source URL may be provided in \a sourceID as well as the \a lineNumber. |
|
1813 |
||
1814 |
The default implementation prints nothing. |
|
1815 |
*/ |
|
1816 |
void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) |
|
1817 |
{ |
|
1818 |
Q_UNUSED(message) |
|
1819 |
Q_UNUSED(lineNumber) |
|
1820 |
Q_UNUSED(sourceID) |
|
1821 |
} |
|
1822 |
||
1823 |
/*! |
|
1824 |
This function is called whenever a JavaScript program running inside \a frame calls the alert() function with |
|
1825 |
the message \a msg. |
|
1826 |
||
1827 |
The default implementation shows the message, \a msg, with QMessageBox::information. |
|
1828 |
*/ |
|
1829 |
void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg) |
|
1830 |
{ |
|
1831 |
Q_UNUSED(frame) |
|
1832 |
#ifndef QT_NO_MESSAGEBOX |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1833 |
QMessageBox::information(view(), tr("JavaScript Alert - %1").arg(mainFrame()->url().host()), msg, QMessageBox::Ok); |
0 | 1834 |
#endif |
1835 |
} |
|
1836 |
||
1837 |
/*! |
|
1838 |
This function is called whenever a JavaScript program running inside \a frame calls the confirm() function |
|
1839 |
with the message, \a msg. Returns true if the user confirms the message; otherwise returns false. |
|
1840 |
||
1841 |
The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons. |
|
1842 |
*/ |
|
1843 |
bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg) |
|
1844 |
{ |
|
1845 |
Q_UNUSED(frame) |
|
1846 |
#ifdef QT_NO_MESSAGEBOX |
|
1847 |
return true; |
|
1848 |
#else |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1849 |
return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()), msg, QMessageBox::Yes, QMessageBox::No); |
0 | 1850 |
#endif |
1851 |
} |
|
1852 |
||
1853 |
/*! |
|
1854 |
This function is called whenever a JavaScript program running inside \a frame tries to prompt the user for input. |
|
1855 |
The program may provide an optional message, \a msg, as well as a default value for the input in \a defaultValue. |
|
1856 |
||
1857 |
If the prompt was cancelled by the user the implementation should return false; otherwise the |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1858 |
result should be written to \a result and true should be returned. If the prompt was not cancelled by the |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1859 |
user, the implementation should return true and the result string must not be null. |
0 | 1860 |
|
1861 |
The default implementation uses QInputDialog::getText. |
|
1862 |
*/ |
|
1863 |
bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result) |
|
1864 |
{ |
|
1865 |
Q_UNUSED(frame) |
|
1866 |
bool ok = false; |
|
1867 |
#ifndef QT_NO_INPUTDIALOG |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1868 |
QString x = QInputDialog::getText(view(), tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()), msg, QLineEdit::Normal, defaultValue, &ok); |
0 | 1869 |
if (ok && result) |
1870 |
*result = x; |
|
1871 |
#endif |
|
1872 |
return ok; |
|
1873 |
} |
|
1874 |
||
1875 |
/*! |
|
1876 |
\fn bool QWebPage::shouldInterruptJavaScript() |
|
1877 |
\since 4.6 |
|
1878 |
This function is called when a JavaScript program is running for a long period of time. |
|
1879 |
||
1880 |
If the user wanted to stop the JavaScript the implementation should return true; otherwise false. |
|
1881 |
||
1882 |
The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons. |
|
1883 |
||
1884 |
\warning Because of binary compatibility constraints, this function is not virtual. If you want to |
|
1885 |
provide your own implementation in a QWebPage subclass, reimplement the shouldInterruptJavaScript() |
|
1886 |
slot in your subclass instead. QtWebKit will dynamically detect the slot and call it. |
|
1887 |
*/ |
|
1888 |
bool QWebPage::shouldInterruptJavaScript() |
|
1889 |
{ |
|
1890 |
#ifdef QT_NO_MESSAGEBOX |
|
1891 |
return false; |
|
1892 |
#else |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1893 |
return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No); |
0 | 1894 |
#endif |
1895 |
} |
|
1896 |
||
1897 |
/*! |
|
1898 |
This function is called whenever WebKit wants to create a new window of the given \a type, for |
|
1899 |
example when a JavaScript program requests to open a document in a new window. |
|
1900 |
||
1901 |
If the new window can be created, the new window's QWebPage is returned; otherwise a null pointer is returned. |
|
1902 |
||
1903 |
If the view associated with the web page is a QWebView object, then the default implementation forwards |
|
1904 |
the request to QWebView's createWindow() function; otherwise it returns a null pointer. |
|
1905 |
||
1906 |
\sa acceptNavigationRequest() |
|
1907 |
*/ |
|
1908 |
QWebPage *QWebPage::createWindow(WebWindowType type) |
|
1909 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1910 |
QWebView *webView = qobject_cast<QWebView *>(view()); |
0 | 1911 |
if (webView) { |
1912 |
QWebView *newView = webView->createWindow(type); |
|
1913 |
if (newView) |
|
1914 |
return newView->page(); |
|
1915 |
} |
|
1916 |
return 0; |
|
1917 |
} |
|
1918 |
||
1919 |
/*! |
|
1920 |
This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin". |
|
1921 |
The \a classid, \a url, \a paramNames and \a paramValues correspond to the HTML object element attributes and |
|
1922 |
child elements to configure the embeddable object. |
|
1923 |
*/ |
|
1924 |
QObject *QWebPage::createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) |
|
1925 |
{ |
|
1926 |
Q_UNUSED(classid) |
|
1927 |
Q_UNUSED(url) |
|
1928 |
Q_UNUSED(paramNames) |
|
1929 |
Q_UNUSED(paramValues) |
|
1930 |
return 0; |
|
1931 |
} |
|
1932 |
||
1933 |
static WebCore::FrameLoadRequest frameLoadRequest(const QUrl &url, WebCore::Frame *frame) |
|
1934 |
{ |
|
1935 |
WebCore::ResourceRequest rr(url, frame->loader()->outgoingReferrer()); |
|
1936 |
return WebCore::FrameLoadRequest(rr); |
|
1937 |
} |
|
1938 |
||
1939 |
static void openNewWindow(const QUrl& url, WebCore::Frame* frame) |
|
1940 |
{ |
|
1941 |
if (Page* oldPage = frame->page()) { |
|
1942 |
WindowFeatures features; |
|
1943 |
if (Page* newPage = oldPage->chrome()->createWindow(frame, |
|
1944 |
frameLoadRequest(url, frame), features)) |
|
1945 |
newPage->chrome()->show(); |
|
1946 |
} |
|
1947 |
} |
|
1948 |
||
1949 |
/*! |
|
1950 |
This function can be called to trigger the specified \a action. |
|
1951 |
It is also called by QtWebKit if the user triggers the action, for example |
|
1952 |
through a context menu item. |
|
1953 |
||
1954 |
If \a action is a checkable action then \a checked specified whether the action |
|
1955 |
is toggled or not. |
|
1956 |
||
1957 |
\sa action() |
|
1958 |
*/ |
|
1959 |
void QWebPage::triggerAction(WebAction action, bool) |
|
1960 |
{ |
|
1961 |
WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame(); |
|
1962 |
if (!frame) |
|
1963 |
return; |
|
1964 |
WebCore::Editor *editor = frame->editor(); |
|
1965 |
const char *command = 0; |
|
1966 |
||
1967 |
switch (action) { |
|
1968 |
case OpenLink: |
|
1969 |
if (QWebFrame *targetFrame = d->hitTestResult.linkTargetFrame()) { |
|
1970 |
WTF::RefPtr<WebCore::Frame> wcFrame = targetFrame->d->frame; |
|
1971 |
targetFrame->d->frame->loader()->loadFrameRequest(frameLoadRequest(d->hitTestResult.linkUrl(), wcFrame.get()), |
|
1972 |
/*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0, |
|
1973 |
/*FormState*/ 0, SendReferrer); |
|
1974 |
break; |
|
1975 |
} |
|
1976 |
// fall through |
|
1977 |
case OpenLinkInNewWindow: |
|
1978 |
openNewWindow(d->hitTestResult.linkUrl(), frame); |
|
1979 |
break; |
|
1980 |
case OpenFrameInNewWindow: { |
|
1981 |
KURL url = frame->loader()->documentLoader()->unreachableURL(); |
|
1982 |
if (url.isEmpty()) |
|
1983 |
url = frame->loader()->documentLoader()->url(); |
|
1984 |
openNewWindow(url, frame); |
|
1985 |
break; |
|
1986 |
} |
|
1987 |
case CopyLinkToClipboard: { |
|
1988 |
#if defined(Q_WS_X11) |
|
1989 |
bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode(); |
|
1990 |
Pasteboard::generalPasteboard()->setSelectionMode(true); |
|
1991 |
editor->copyURL(d->hitTestResult.linkUrl(), d->hitTestResult.linkText()); |
|
1992 |
Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode); |
|
1993 |
#endif |
|
1994 |
editor->copyURL(d->hitTestResult.linkUrl(), d->hitTestResult.linkText()); |
|
1995 |
break; |
|
1996 |
} |
|
1997 |
case OpenImageInNewWindow: |
|
1998 |
openNewWindow(d->hitTestResult.imageUrl(), frame); |
|
1999 |
break; |
|
2000 |
case DownloadImageToDisk: |
|
2001 |
frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->hitTestResult.imageUrl(), frame->loader()->outgoingReferrer())); |
|
2002 |
break; |
|
2003 |
case DownloadLinkToDisk: |
|
2004 |
frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->hitTestResult.linkUrl(), frame->loader()->outgoingReferrer())); |
|
2005 |
break; |
|
2006 |
#ifndef QT_NO_CLIPBOARD |
|
2007 |
case CopyImageToClipboard: |
|
2008 |
QApplication::clipboard()->setPixmap(d->hitTestResult.pixmap()); |
|
2009 |
break; |
|
2010 |
#endif |
|
2011 |
case Back: |
|
2012 |
d->page->goBack(); |
|
2013 |
break; |
|
2014 |
case Forward: |
|
2015 |
d->page->goForward(); |
|
2016 |
break; |
|
2017 |
case Stop: |
|
2018 |
mainFrame()->d->frame->loader()->stopForUserCancel(); |
|
2019 |
break; |
|
2020 |
case Reload: |
|
2021 |
mainFrame()->d->frame->loader()->reload(/*endtoendreload*/false); |
|
2022 |
break; |
|
2023 |
case ReloadAndBypassCache: |
|
2024 |
mainFrame()->d->frame->loader()->reload(/*endtoendreload*/true); |
|
2025 |
break; |
|
2026 |
case SetTextDirectionDefault: |
|
2027 |
editor->setBaseWritingDirection(NaturalWritingDirection); |
|
2028 |
break; |
|
2029 |
case SetTextDirectionLeftToRight: |
|
2030 |
editor->setBaseWritingDirection(LeftToRightWritingDirection); |
|
2031 |
break; |
|
2032 |
case SetTextDirectionRightToLeft: |
|
2033 |
editor->setBaseWritingDirection(RightToLeftWritingDirection); |
|
2034 |
break; |
|
2035 |
case InspectElement: { |
|
2036 |
if (!d->hitTestResult.isNull()) { |
|
2037 |
d->getOrCreateInspector(); // Make sure the inspector is created |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2038 |
d->inspector->show(); // The inspector is expected to be shown on inspection |
0 | 2039 |
d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get()); |
2040 |
} |
|
2041 |
break; |
|
2042 |
} |
|
2043 |
default: |
|
2044 |
command = QWebPagePrivate::editorCommandForWebActions(action); |
|
2045 |
break; |
|
2046 |
} |
|
2047 |
||
2048 |
if (command) |
|
2049 |
editor->command(command).execute(); |
|
2050 |
} |
|
2051 |
||
2052 |
QSize QWebPage::viewportSize() const |
|
2053 |
{ |
|
2054 |
if (d->mainFrame && d->mainFrame->d->frame->view()) |
|
2055 |
return d->mainFrame->d->frame->view()->frameRect().size(); |
|
2056 |
||
2057 |
return d->viewportSize; |
|
2058 |
} |
|
2059 |
||
2060 |
/*! |
|
2061 |
\property QWebPage::viewportSize |
|
2062 |
\brief the size of the viewport |
|
2063 |
||
2064 |
The size affects for example the visibility of scrollbars |
|
2065 |
if the document is larger than the viewport. |
|
2066 |
||
2067 |
By default, for a newly-created Web page, this property contains a size with |
|
2068 |
zero width and height. |
|
2069 |
*/ |
|
2070 |
void QWebPage::setViewportSize(const QSize &size) const |
|
2071 |
{ |
|
2072 |
d->viewportSize = size; |
|
2073 |
||
2074 |
QWebFrame *frame = mainFrame(); |
|
2075 |
if (frame->d->frame && frame->d->frame->view()) { |
|
2076 |
WebCore::FrameView* view = frame->d->frame->view(); |
|
2077 |
view->setFrameRect(QRect(QPoint(0, 0), size)); |
|
2078 |
view->forceLayout(); |
|
2079 |
view->adjustViewSize(); |
|
2080 |
} |
|
2081 |
} |
|
2082 |
||
2083 |
QSize QWebPage::preferredContentsSize() const |
|
2084 |
{ |
|
2085 |
QWebFrame* frame = d->mainFrame; |
|
2086 |
if (frame) { |
|
2087 |
WebCore::FrameView* view = frame->d->frame->view(); |
|
2088 |
if (view && view->useFixedLayout()) |
|
2089 |
return d->mainFrame->d->frame->view()->fixedLayoutSize(); |
|
2090 |
} |
|
2091 |
||
2092 |
return d->fixedLayoutSize; |
|
2093 |
} |
|
2094 |
||
2095 |
/*! |
|
2096 |
\property QWebPage::preferredContentsSize |
|
2097 |
\since 4.6 |
|
2098 |
\brief the size of the fixed layout |
|
2099 |
||
2100 |
The size affects the layout of the page in the viewport. If set to a fixed size of |
|
2101 |
1024x768 for example then webkit will layout the page as if the viewport were that size |
|
2102 |
rather than something different. |
|
2103 |
*/ |
|
2104 |
void QWebPage::setPreferredContentsSize(const QSize &size) const |
|
2105 |
{ |
|
2106 |
d->fixedLayoutSize = size; |
|
2107 |
||
2108 |
QWebFrame *frame = mainFrame(); |
|
2109 |
if (frame->d->frame && frame->d->frame->view()) { |
|
2110 |
WebCore::FrameView* view = frame->d->frame->view(); |
|
2111 |
||
2112 |
if (size.isValid()) { |
|
2113 |
view->setUseFixedLayout(true); |
|
2114 |
view->setFixedLayoutSize(size); |
|
2115 |
view->forceLayout(); |
|
2116 |
} else if (view->useFixedLayout()) { |
|
2117 |
view->setUseFixedLayout(false); |
|
2118 |
view->forceLayout(); |
|
2119 |
} |
|
2120 |
} |
|
2121 |
} |
|
2122 |
||
2123 |
/*! |
|
2124 |
\fn bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) |
|
2125 |
||
2126 |
This function is called whenever WebKit requests to navigate \a frame to the resource specified by \a request by means of |
|
2127 |
the specified navigation type \a type. |
|
2128 |
||
2129 |
If \a frame is a null pointer then navigation to a new window is requested. If the request is |
|
2130 |
accepted createWindow() will be called. |
|
2131 |
||
2132 |
The default implementation interprets the page's linkDelegationPolicy and emits linkClicked accordingly or returns true |
|
2133 |
to let QWebPage handle the navigation itself. |
|
2134 |
||
2135 |
\sa createWindow() |
|
2136 |
*/ |
|
2137 |
#if QT_VERSION >= 0x040400 |
|
2138 |
bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) |
|
2139 |
#else |
|
2140 |
bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type) |
|
2141 |
#endif |
|
2142 |
{ |
|
2143 |
Q_UNUSED(frame) |
|
2144 |
if (type == NavigationTypeLinkClicked) { |
|
2145 |
switch (d->linkPolicy) { |
|
2146 |
case DontDelegateLinks: |
|
2147 |
return true; |
|
2148 |
||
2149 |
case DelegateExternalLinks: |
|
2150 |
if (WebCore::SecurityOrigin::shouldTreatURLSchemeAsLocal(request.url().scheme())) |
|
2151 |
return true; |
|
2152 |
emit linkClicked(request.url()); |
|
2153 |
return false; |
|
2154 |
||
2155 |
case DelegateAllLinks: |
|
2156 |
emit linkClicked(request.url()); |
|
2157 |
return false; |
|
2158 |
} |
|
2159 |
} |
|
2160 |
return true; |
|
2161 |
} |
|
2162 |
||
2163 |
/*! |
|
2164 |
\property QWebPage::selectedText |
|
2165 |
\brief the text currently selected |
|
2166 |
||
2167 |
By default, this property contains an empty string. |
|
2168 |
||
2169 |
\sa selectionChanged() |
|
2170 |
*/ |
|
2171 |
QString QWebPage::selectedText() const |
|
2172 |
{ |
|
2173 |
d->createMainFrame(); |
|
2174 |
return d->page->focusController()->focusedOrMainFrame()->selectedText(); |
|
2175 |
} |
|
2176 |
||
2177 |
/*! |
|
2178 |
Returns a QAction for the specified WebAction \a action. |
|
2179 |
||
2180 |
The action is owned by the QWebPage but you can customize the look by |
|
2181 |
changing its properties. |
|
2182 |
||
2183 |
QWebPage also takes care of implementing the action, so that upon |
|
2184 |
triggering the corresponding action is performed on the page. |
|
2185 |
||
2186 |
\sa triggerAction() |
|
2187 |
*/ |
|
2188 |
QAction *QWebPage::action(WebAction action) const |
|
2189 |
{ |
|
2190 |
if (action == QWebPage::NoWebAction) return 0; |
|
2191 |
if (d->actions[action]) |
|
2192 |
return d->actions[action]; |
|
2193 |
||
2194 |
QString text; |
|
2195 |
QIcon icon; |
|
2196 |
QStyle *style = view() ? view()->style() : qApp->style(); |
|
2197 |
bool checkable = false; |
|
2198 |
||
2199 |
switch (action) { |
|
2200 |
case OpenLink: |
|
2201 |
text = contextMenuItemTagOpenLink(); |
|
2202 |
break; |
|
2203 |
case OpenLinkInNewWindow: |
|
2204 |
text = contextMenuItemTagOpenLinkInNewWindow(); |
|
2205 |
break; |
|
2206 |
case OpenFrameInNewWindow: |
|
2207 |
text = contextMenuItemTagOpenFrameInNewWindow(); |
|
2208 |
break; |
|
2209 |
||
2210 |
case DownloadLinkToDisk: |
|
2211 |
text = contextMenuItemTagDownloadLinkToDisk(); |
|
2212 |
break; |
|
2213 |
case CopyLinkToClipboard: |
|
2214 |
text = contextMenuItemTagCopyLinkToClipboard(); |
|
2215 |
break; |
|
2216 |
||
2217 |
case OpenImageInNewWindow: |
|
2218 |
text = contextMenuItemTagOpenImageInNewWindow(); |
|
2219 |
break; |
|
2220 |
case DownloadImageToDisk: |
|
2221 |
text = contextMenuItemTagDownloadImageToDisk(); |
|
2222 |
break; |
|
2223 |
case CopyImageToClipboard: |
|
2224 |
text = contextMenuItemTagCopyImageToClipboard(); |
|
2225 |
break; |
|
2226 |
||
2227 |
case Back: |
|
2228 |
text = contextMenuItemTagGoBack(); |
|
2229 |
#if QT_VERSION >= 0x040400 |
|
2230 |
icon = style->standardIcon(QStyle::SP_ArrowBack); |
|
2231 |
#endif |
|
2232 |
break; |
|
2233 |
case Forward: |
|
2234 |
text = contextMenuItemTagGoForward(); |
|
2235 |
#if QT_VERSION >= 0x040400 |
|
2236 |
icon = style->standardIcon(QStyle::SP_ArrowForward); |
|
2237 |
#endif |
|
2238 |
break; |
|
2239 |
case Stop: |
|
2240 |
text = contextMenuItemTagStop(); |
|
2241 |
#if QT_VERSION >= 0x040400 |
|
2242 |
icon = style->standardIcon(QStyle::SP_BrowserStop); |
|
2243 |
#endif |
|
2244 |
break; |
|
2245 |
case Reload: |
|
2246 |
text = contextMenuItemTagReload(); |
|
2247 |
#if QT_VERSION >= 0x040400 |
|
2248 |
icon = style->standardIcon(QStyle::SP_BrowserReload); |
|
2249 |
#endif |
|
2250 |
break; |
|
2251 |
||
2252 |
case Cut: |
|
2253 |
text = contextMenuItemTagCut(); |
|
2254 |
break; |
|
2255 |
case Copy: |
|
2256 |
text = contextMenuItemTagCopy(); |
|
2257 |
break; |
|
2258 |
case Paste: |
|
2259 |
text = contextMenuItemTagPaste(); |
|
2260 |
break; |
|
2261 |
#ifndef QT_NO_UNDOSTACK |
|
2262 |
case Undo: { |
|
2263 |
QAction *a = undoStack()->createUndoAction(d->q); |
|
2264 |
d->actions[action] = a; |
|
2265 |
return a; |
|
2266 |
} |
|
2267 |
case Redo: { |
|
2268 |
QAction *a = undoStack()->createRedoAction(d->q); |
|
2269 |
d->actions[action] = a; |
|
2270 |
return a; |
|
2271 |
} |
|
2272 |
#endif // QT_NO_UNDOSTACK |
|
2273 |
case MoveToNextChar: |
|
2274 |
text = tr("Move the cursor to the next character"); |
|
2275 |
break; |
|
2276 |
case MoveToPreviousChar: |
|
2277 |
text = tr("Move the cursor to the previous character"); |
|
2278 |
break; |
|
2279 |
case MoveToNextWord: |
|
2280 |
text = tr("Move the cursor to the next word"); |
|
2281 |
break; |
|
2282 |
case MoveToPreviousWord: |
|
2283 |
text = tr("Move the cursor to the previous word"); |
|
2284 |
break; |
|
2285 |
case MoveToNextLine: |
|
2286 |
text = tr("Move the cursor to the next line"); |
|
2287 |
break; |
|
2288 |
case MoveToPreviousLine: |
|
2289 |
text = tr("Move the cursor to the previous line"); |
|
2290 |
break; |
|
2291 |
case MoveToStartOfLine: |
|
2292 |
text = tr("Move the cursor to the start of the line"); |
|
2293 |
break; |
|
2294 |
case MoveToEndOfLine: |
|
2295 |
text = tr("Move the cursor to the end of the line"); |
|
2296 |
break; |
|
2297 |
case MoveToStartOfBlock: |
|
2298 |
text = tr("Move the cursor to the start of the block"); |
|
2299 |
break; |
|
2300 |
case MoveToEndOfBlock: |
|
2301 |
text = tr("Move the cursor to the end of the block"); |
|
2302 |
break; |
|
2303 |
case MoveToStartOfDocument: |
|
2304 |
text = tr("Move the cursor to the start of the document"); |
|
2305 |
break; |
|
2306 |
case MoveToEndOfDocument: |
|
2307 |
text = tr("Move the cursor to the end of the document"); |
|
2308 |
break; |
|
2309 |
case SelectAll: |
|
2310 |
text = tr("Select all"); |
|
2311 |
break; |
|
2312 |
case SelectNextChar: |
|
2313 |
text = tr("Select to the next character"); |
|
2314 |
break; |
|
2315 |
case SelectPreviousChar: |
|
2316 |
text = tr("Select to the previous character"); |
|
2317 |
break; |
|
2318 |
case SelectNextWord: |
|
2319 |
text = tr("Select to the next word"); |
|
2320 |
break; |
|
2321 |
case SelectPreviousWord: |
|
2322 |
text = tr("Select to the previous word"); |
|
2323 |
break; |
|
2324 |
case SelectNextLine: |
|
2325 |
text = tr("Select to the next line"); |
|
2326 |
break; |
|
2327 |
case SelectPreviousLine: |
|
2328 |
text = tr("Select to the previous line"); |
|
2329 |
break; |
|
2330 |
case SelectStartOfLine: |
|
2331 |
text = tr("Select to the start of the line"); |
|
2332 |
break; |
|
2333 |
case SelectEndOfLine: |
|
2334 |
text = tr("Select to the end of the line"); |
|
2335 |
break; |
|
2336 |
case SelectStartOfBlock: |
|
2337 |
text = tr("Select to the start of the block"); |
|
2338 |
break; |
|
2339 |
case SelectEndOfBlock: |
|
2340 |
text = tr("Select to the end of the block"); |
|
2341 |
break; |
|
2342 |
case SelectStartOfDocument: |
|
2343 |
text = tr("Select to the start of the document"); |
|
2344 |
break; |
|
2345 |
case SelectEndOfDocument: |
|
2346 |
text = tr("Select to the end of the document"); |
|
2347 |
break; |
|
2348 |
case DeleteStartOfWord: |
|
2349 |
text = tr("Delete to the start of the word"); |
|
2350 |
break; |
|
2351 |
case DeleteEndOfWord: |
|
2352 |
text = tr("Delete to the end of the word"); |
|
2353 |
break; |
|
2354 |
||
2355 |
case SetTextDirectionDefault: |
|
2356 |
text = contextMenuItemTagDefaultDirection(); |
|
2357 |
break; |
|
2358 |
case SetTextDirectionLeftToRight: |
|
2359 |
text = contextMenuItemTagLeftToRight(); |
|
2360 |
checkable = true; |
|
2361 |
break; |
|
2362 |
case SetTextDirectionRightToLeft: |
|
2363 |
text = contextMenuItemTagRightToLeft(); |
|
2364 |
checkable = true; |
|
2365 |
break; |
|
2366 |
||
2367 |
case ToggleBold: |
|
2368 |
text = contextMenuItemTagBold(); |
|
2369 |
checkable = true; |
|
2370 |
break; |
|
2371 |
case ToggleItalic: |
|
2372 |
text = contextMenuItemTagItalic(); |
|
2373 |
checkable = true; |
|
2374 |
break; |
|
2375 |
case ToggleUnderline: |
|
2376 |
text = contextMenuItemTagUnderline(); |
|
2377 |
checkable = true; |
|
2378 |
break; |
|
2379 |
||
2380 |
case InspectElement: |
|
2381 |
text = contextMenuItemTagInspectElement(); |
|
2382 |
break; |
|
2383 |
||
2384 |
case InsertParagraphSeparator: |
|
2385 |
text = tr("Insert a new paragraph"); |
|
2386 |
break; |
|
2387 |
case InsertLineSeparator: |
|
2388 |
text = tr("Insert a new line"); |
|
2389 |
break; |
|
2390 |
||
2391 |
case PasteAndMatchStyle: |
|
2392 |
text = tr("Paste and Match Style"); |
|
2393 |
break; |
|
2394 |
case RemoveFormat: |
|
2395 |
text = tr("Remove formatting"); |
|
2396 |
break; |
|
2397 |
||
2398 |
case ToggleStrikethrough: |
|
2399 |
text = tr("Strikethrough"); |
|
2400 |
checkable = true; |
|
2401 |
break; |
|
2402 |
case ToggleSubscript: |
|
2403 |
text = tr("Subscript"); |
|
2404 |
checkable = true; |
|
2405 |
break; |
|
2406 |
case ToggleSuperscript: |
|
2407 |
text = tr("Superscript"); |
|
2408 |
checkable = true; |
|
2409 |
break; |
|
2410 |
case InsertUnorderedList: |
|
2411 |
text = tr("Insert Bulleted List"); |
|
2412 |
checkable = true; |
|
2413 |
break; |
|
2414 |
case InsertOrderedList: |
|
2415 |
text = tr("Insert Numbered List"); |
|
2416 |
checkable = true; |
|
2417 |
break; |
|
2418 |
case Indent: |
|
2419 |
text = tr("Indent"); |
|
2420 |
break; |
|
2421 |
case Outdent: |
|
2422 |
text = tr("Outdent"); |
|
2423 |
break; |
|
2424 |
case AlignCenter: |
|
2425 |
text = tr("Center"); |
|
2426 |
break; |
|
2427 |
case AlignJustified: |
|
2428 |
text = tr("Justify"); |
|
2429 |
break; |
|
2430 |
case AlignLeft: |
|
2431 |
text = tr("Align Left"); |
|
2432 |
break; |
|
2433 |
case AlignRight: |
|
2434 |
text = tr("Align Right"); |
|
2435 |
break; |
|
2436 |
||
2437 |
case NoWebAction: |
|
2438 |
return 0; |
|
2439 |
} |
|
2440 |
||
2441 |
if (text.isEmpty()) |
|
2442 |
return 0; |
|
2443 |
||
2444 |
QAction *a = new QAction(d->q); |
|
2445 |
a->setText(text); |
|
2446 |
a->setData(action); |
|
2447 |
a->setCheckable(checkable); |
|
2448 |
a->setIcon(icon); |
|
2449 |
||
2450 |
connect(a, SIGNAL(triggered(bool)), |
|
2451 |
this, SLOT(_q_webActionTriggered(bool))); |
|
2452 |
||
2453 |
d->actions[action] = a; |
|
2454 |
d->updateAction(action); |
|
2455 |
return a; |
|
2456 |
} |
|
2457 |
||
2458 |
/*! |
|
2459 |
\property QWebPage::modified |
|
2460 |
\brief whether the page contains unsubmitted form data |
|
2461 |
||
2462 |
By default, this property is false. |
|
2463 |
*/ |
|
2464 |
bool QWebPage::isModified() const |
|
2465 |
{ |
|
2466 |
#ifdef QT_NO_UNDOSTACK |
|
2467 |
return false; |
|
2468 |
#else |
|
2469 |
if (!d->undoStack) |
|
2470 |
return false; |
|
2471 |
return d->undoStack->canUndo(); |
|
2472 |
#endif // QT_NO_UNDOSTACK |
|
2473 |
} |
|
2474 |
||
2475 |
#ifndef QT_NO_UNDOSTACK |
|
2476 |
/*! |
|
2477 |
Returns a pointer to the undo stack used for editable content. |
|
2478 |
*/ |
|
2479 |
QUndoStack *QWebPage::undoStack() const |
|
2480 |
{ |
|
2481 |
if (!d->undoStack) |
|
2482 |
d->undoStack = new QUndoStack(const_cast<QWebPage *>(this)); |
|
2483 |
||
2484 |
return d->undoStack; |
|
2485 |
} |
|
2486 |
#endif // QT_NO_UNDOSTACK |
|
2487 |
||
2488 |
/*! \reimp |
|
2489 |
*/ |
|
2490 |
bool QWebPage::event(QEvent *ev) |
|
2491 |
{ |
|
2492 |
switch (ev->type()) { |
|
2493 |
case QEvent::Timer: |
|
2494 |
d->timerEvent(static_cast<QTimerEvent*>(ev)); |
|
2495 |
break; |
|
2496 |
case QEvent::MouseMove: |
|
2497 |
d->mouseMoveEvent(static_cast<QMouseEvent*>(ev)); |
|
2498 |
break; |
|
2499 |
case QEvent::GraphicsSceneMouseMove: |
|
2500 |
d->mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(ev)); |
|
2501 |
break; |
|
2502 |
case QEvent::MouseButtonPress: |
|
2503 |
d->mousePressEvent(static_cast<QMouseEvent*>(ev)); |
|
2504 |
break; |
|
2505 |
case QEvent::GraphicsSceneMousePress: |
|
2506 |
d->mousePressEvent(static_cast<QGraphicsSceneMouseEvent*>(ev)); |
|
2507 |
break; |
|
2508 |
case QEvent::MouseButtonDblClick: |
|
2509 |
d->mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev)); |
|
2510 |
break; |
|
2511 |
case QEvent::GraphicsSceneMouseDoubleClick: |
|
2512 |
d->mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent*>(ev)); |
|
2513 |
break; |
|
2514 |
case QEvent::MouseButtonRelease: |
|
2515 |
d->mouseReleaseEvent(static_cast<QMouseEvent*>(ev)); |
|
2516 |
break; |
|
2517 |
case QEvent::GraphicsSceneMouseRelease: |
|
2518 |
d->mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(ev)); |
|
2519 |
break; |
|
2520 |
#ifndef QT_NO_CONTEXTMENU |
|
2521 |
case QEvent::ContextMenu: |
|
2522 |
d->contextMenuEvent(static_cast<QContextMenuEvent*>(ev)->globalPos()); |
|
2523 |
break; |
|
2524 |
case QEvent::GraphicsSceneContextMenu: |
|
2525 |
d->contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent*>(ev)->screenPos()); |
|
2526 |
break; |
|
2527 |
#endif |
|
2528 |
#ifndef QT_NO_WHEELEVENT |
|
2529 |
case QEvent::Wheel: |
|
2530 |
d->wheelEvent(static_cast<QWheelEvent*>(ev)); |
|
2531 |
break; |
|
2532 |
case QEvent::GraphicsSceneWheel: |
|
2533 |
d->wheelEvent(static_cast<QGraphicsSceneWheelEvent*>(ev)); |
|
2534 |
break; |
|
2535 |
#endif |
|
2536 |
case QEvent::KeyPress: |
|
2537 |
d->keyPressEvent(static_cast<QKeyEvent*>(ev)); |
|
2538 |
break; |
|
2539 |
case QEvent::KeyRelease: |
|
2540 |
d->keyReleaseEvent(static_cast<QKeyEvent*>(ev)); |
|
2541 |
break; |
|
2542 |
case QEvent::FocusIn: |
|
2543 |
d->focusInEvent(static_cast<QFocusEvent*>(ev)); |
|
2544 |
break; |
|
2545 |
case QEvent::FocusOut: |
|
2546 |
d->focusOutEvent(static_cast<QFocusEvent*>(ev)); |
|
2547 |
break; |
|
2548 |
#ifndef QT_NO_DRAGANDDROP |
|
2549 |
case QEvent::DragEnter: |
|
2550 |
d->dragEnterEvent(static_cast<QDragEnterEvent*>(ev)); |
|
2551 |
break; |
|
2552 |
case QEvent::GraphicsSceneDragEnter: |
|
2553 |
d->dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent*>(ev)); |
|
2554 |
break; |
|
2555 |
case QEvent::DragLeave: |
|
2556 |
d->dragLeaveEvent(static_cast<QDragLeaveEvent*>(ev)); |
|
2557 |
break; |
|
2558 |
case QEvent::GraphicsSceneDragLeave: |
|
2559 |
d->dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent*>(ev)); |
|
2560 |
break; |
|
2561 |
case QEvent::DragMove: |
|
2562 |
d->dragMoveEvent(static_cast<QDragMoveEvent*>(ev)); |
|
2563 |
break; |
|
2564 |
case QEvent::GraphicsSceneDragMove: |
|
2565 |
d->dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent*>(ev)); |
|
2566 |
break; |
|
2567 |
case QEvent::Drop: |
|
2568 |
d->dropEvent(static_cast<QDropEvent*>(ev)); |
|
2569 |
break; |
|
2570 |
case QEvent::GraphicsSceneDrop: |
|
2571 |
d->dropEvent(static_cast<QGraphicsSceneDragDropEvent*>(ev)); |
|
2572 |
break; |
|
2573 |
#endif |
|
2574 |
case QEvent::InputMethod: |
|
2575 |
d->inputMethodEvent(static_cast<QInputMethodEvent*>(ev)); |
|
2576 |
case QEvent::ShortcutOverride: |
|
2577 |
d->shortcutOverrideEvent(static_cast<QKeyEvent*>(ev)); |
|
2578 |
break; |
|
2579 |
case QEvent::Leave: |
|
2580 |
d->leaveEvent(ev); |
|
2581 |
break; |
|
2582 |
default: |
|
2583 |
return QObject::event(ev); |
|
2584 |
} |
|
2585 |
||
2586 |
return true; |
|
2587 |
} |
|
2588 |
||
2589 |
/*! |
|
2590 |
Similar to QWidget::focusNextPrevChild it focuses the next focusable web element |
|
2591 |
if \a next is true; otherwise the previous element is focused. |
|
2592 |
||
2593 |
Returns true if it can find a new focusable element, or false if it can't. |
|
2594 |
*/ |
|
2595 |
bool QWebPage::focusNextPrevChild(bool next) |
|
2596 |
{ |
|
2597 |
QKeyEvent ev(QEvent::KeyPress, Qt::Key_Tab, Qt::KeyboardModifiers(next ? Qt::NoModifier : Qt::ShiftModifier)); |
|
2598 |
d->keyPressEvent(&ev); |
|
2599 |
bool hasFocusedNode = false; |
|
2600 |
Frame *frame = d->page->focusController()->focusedFrame(); |
|
2601 |
if (frame) { |
|
2602 |
Document *document = frame->document(); |
|
2603 |
hasFocusedNode = document && document->focusedNode(); |
|
2604 |
} |
|
2605 |
//qDebug() << "focusNextPrevChild(" << next << ") =" << ev.isAccepted() << "focusedNode?" << hasFocusedNode; |
|
2606 |
return hasFocusedNode; |
|
2607 |
} |
|
2608 |
||
2609 |
/*! |
|
2610 |
\property QWebPage::contentEditable |
|
2611 |
\brief whether the content in this QWebPage is editable or not |
|
2612 |
\since 4.5 |
|
2613 |
||
2614 |
If this property is enabled the contents of the page can be edited by the user through a visible |
|
2615 |
cursor. If disabled (the default) only HTML elements in the web page with their |
|
2616 |
\c{contenteditable} attribute set are editable. |
|
2617 |
*/ |
|
2618 |
void QWebPage::setContentEditable(bool editable) |
|
2619 |
{ |
|
2620 |
if (d->editable != editable) { |
|
2621 |
d->editable = editable; |
|
2622 |
d->page->setTabKeyCyclesThroughElements(!editable); |
|
2623 |
if (d->mainFrame) { |
|
2624 |
WebCore::Frame* frame = d->mainFrame->d->frame; |
|
2625 |
if (editable) { |
|
2626 |
frame->applyEditingStyleToBodyElement(); |
|
2627 |
// FIXME: mac port calls this if there is no selectedDOMRange |
|
2628 |
//frame->setSelectionFromNone(); |
|
2629 |
} else |
|
2630 |
frame->removeEditingStyleFromBodyElement(); |
|
2631 |
} |
|
2632 |
||
2633 |
d->updateEditorActions(); |
|
2634 |
} |
|
2635 |
} |
|
2636 |
||
2637 |
bool QWebPage::isContentEditable() const |
|
2638 |
{ |
|
2639 |
return d->editable; |
|
2640 |
} |
|
2641 |
||
2642 |
/*! |
|
2643 |
\property QWebPage::forwardUnsupportedContent |
|
2644 |
\brief whether QWebPage should forward unsupported content |
|
2645 |
||
2646 |
If enabled, the unsupportedContent() signal is emitted with a network reply that |
|
2647 |
can be used to read the content. |
|
2648 |
||
2649 |
If disabled, the download of such content is aborted immediately. |
|
2650 |
||
2651 |
By default unsupported content is not forwarded. |
|
2652 |
*/ |
|
2653 |
||
2654 |
void QWebPage::setForwardUnsupportedContent(bool forward) |
|
2655 |
{ |
|
2656 |
d->forwardUnsupportedContent = forward; |
|
2657 |
} |
|
2658 |
||
2659 |
bool QWebPage::forwardUnsupportedContent() const |
|
2660 |
{ |
|
2661 |
return d->forwardUnsupportedContent; |
|
2662 |
} |
|
2663 |
||
2664 |
/*! |
|
2665 |
\property QWebPage::linkDelegationPolicy |
|
2666 |
\brief how QWebPage should delegate the handling of links through the |
|
2667 |
linkClicked() signal |
|
2668 |
||
2669 |
The default is to delegate no links. |
|
2670 |
*/ |
|
2671 |
||
2672 |
void QWebPage::setLinkDelegationPolicy(LinkDelegationPolicy policy) |
|
2673 |
{ |
|
2674 |
d->linkPolicy = policy; |
|
2675 |
} |
|
2676 |
||
2677 |
QWebPage::LinkDelegationPolicy QWebPage::linkDelegationPolicy() const |
|
2678 |
{ |
|
2679 |
return d->linkPolicy; |
|
2680 |
} |
|
2681 |
||
2682 |
#ifndef QT_NO_CONTEXTMENU |
|
2683 |
/*! |
|
2684 |
Filters the context menu event, \a event, through handlers for scrollbars and |
|
2685 |
custom event handlers in the web page. Returns true if the event was handled; |
|
2686 |
otherwise false. |
|
2687 |
||
2688 |
A web page may swallow a context menu event through a custom event handler, allowing for context |
|
2689 |
menus to be implemented in HTML/JavaScript. This is used by \l{http://maps.google.com/}{Google |
|
2690 |
Maps}, for example. |
|
2691 |
*/ |
|
2692 |
bool QWebPage::swallowContextMenuEvent(QContextMenuEvent *event) |
|
2693 |
{ |
|
2694 |
d->page->contextMenuController()->clearContextMenu(); |
|
2695 |
||
2696 |
if (QWebFrame* webFrame = frameAt(event->pos())) { |
|
2697 |
Frame* frame = QWebFramePrivate::core(webFrame); |
|
2698 |
if (Scrollbar* scrollbar = frame->view()->scrollbarAtPoint(PlatformMouseEvent(event, 1).pos())) |
|
2699 |
return scrollbar->contextMenu(PlatformMouseEvent(event, 1)); |
|
2700 |
} |
|
2701 |
||
2702 |
WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame(); |
|
2703 |
focusedFrame->eventHandler()->sendContextMenuEvent(PlatformMouseEvent(event, 1)); |
|
2704 |
ContextMenu *menu = d->page->contextMenuController()->contextMenu(); |
|
2705 |
// If the website defines its own handler then sendContextMenuEvent takes care of |
|
2706 |
// calling/showing it and the context menu pointer will be zero. This is the case |
|
2707 |
// on maps.google.com for example. |
|
2708 |
||
2709 |
return !menu; |
|
2710 |
} |
|
2711 |
#endif // QT_NO_CONTEXTMENU |
|
2712 |
||
2713 |
/*! |
|
2714 |
Updates the page's actions depending on the position \a pos. For example if \a pos is over an image |
|
2715 |
element the CopyImageToClipboard action is enabled. |
|
2716 |
*/ |
|
2717 |
void QWebPage::updatePositionDependentActions(const QPoint &pos) |
|
2718 |
{ |
|
2719 |
// First we disable all actions, but keep track of which ones were originally enabled. |
|
2720 |
QBitArray originallyEnabledWebActions(QWebPage::WebActionCount); |
|
2721 |
for (int i = ContextMenuItemTagNoAction; i < ContextMenuItemBaseApplicationTag; ++i) { |
|
2722 |
QWebPage::WebAction action = webActionForContextMenuAction(WebCore::ContextMenuAction(i)); |
|
2723 |
if (QAction *a = this->action(action)) { |
|
2724 |
originallyEnabledWebActions.setBit(action, a->isEnabled()); |
|
2725 |
a->setEnabled(false); |
|
2726 |
} |
|
2727 |
} |
|
2728 |
||
2729 |
d->createMainFrame(); |
|
2730 |
WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame(); |
|
2731 |
HitTestResult result = focusedFrame->eventHandler()->hitTestResultAtPoint(focusedFrame->view()->windowToContents(pos), /*allowShadowContent*/ false); |
|
2732 |
||
2733 |
if (result.scrollbar()) |
|
2734 |
d->hitTestResult = QWebHitTestResult(); |
|
2735 |
else |
|
2736 |
d->hitTestResult = QWebHitTestResult(new QWebHitTestResultPrivate(result)); |
|
2737 |
WebCore::ContextMenu menu(result); |
|
2738 |
menu.populate(); |
|
2739 |
if (d->page->inspectorController()->enabled()) |
|
2740 |
menu.addInspectElementItem(); |
|
2741 |
||
2742 |
QBitArray visitedWebActions(QWebPage::WebActionCount); |
|
2743 |
||
2744 |
#ifndef QT_NO_CONTEXTMENU |
|
2745 |
delete d->currentContextMenu; |
|
2746 |
||
2747 |
// Then we let createContextMenu() enable the actions that are put into the menu |
|
2748 |
d->currentContextMenu = d->createContextMenu(&menu, menu.platformDescription(), &visitedWebActions); |
|
2749 |
#endif // QT_NO_CONTEXTMENU |
|
2750 |
||
2751 |
// Finally, we restore the original enablement for the actions that were not put into the menu. |
|
2752 |
originallyEnabledWebActions &= ~visitedWebActions; // Mask out visited actions (they're part of the menu) |
|
2753 |
for (int i = 0; i < QWebPage::WebActionCount; ++i) { |
|
2754 |
if (originallyEnabledWebActions.at(i)) { |
|
2755 |
if (QAction *a = this->action(QWebPage::WebAction(i))) |
|
2756 |
a->setEnabled(true); |
|
2757 |
} |
|
2758 |
} |
|
2759 |
||
2760 |
// This whole process ensures that any actions put into to the context menu has the right |
|
2761 |
// enablement, while also keeping the correct enablement for actions that were left out of |
|
2762 |
// the menu. |
|
2763 |
||
2764 |
} |
|
2765 |
||
2766 |
||
2767 |
||
2768 |
/*! |
|
2769 |
\enum QWebPage::Extension |
|
2770 |
||
2771 |
This enum describes the types of extensions that the page can support. Before using these extensions, you |
|
2772 |
should verify that the extension is supported by calling supportsExtension(). |
|
2773 |
||
2774 |
\value ChooseMultipleFilesExtension Whether the web page supports multiple file selection. |
|
2775 |
This extension is invoked when the web content requests one or more file names, for example |
|
2776 |
as a result of the user clicking on a "file upload" button in a HTML form where multiple |
|
2777 |
file selection is allowed. |
|
2778 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2779 |
\omitvalue ErrorPageExtension (introduced in Qt 4.6) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2780 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2781 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2782 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2783 |
\enum QWebPage::ErrorDomain |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2784 |
\since 4.6 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2785 |
\internal |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2786 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2787 |
\value QtNetwork |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2788 |
\value Http |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2789 |
\value WebKit |
0 | 2790 |
*/ |
2791 |
||
2792 |
/*! |
|
2793 |
\class QWebPage::ExtensionOption |
|
2794 |
\since 4.4 |
|
2795 |
\brief The ExtensionOption class provides an extended input argument to QWebPage's extension support. |
|
2796 |
||
2797 |
\inmodule QtWebKit |
|
2798 |
||
2799 |
\sa QWebPage::extension() |
|
2800 |
*/ |
|
2801 |
||
2802 |
/*! |
|
2803 |
\class QWebPage::ErrorPageExtensionOption |
|
2804 |
\since 4.6 |
|
2805 |
\brief The ErrorPageExtensionOption class describes the option |
|
2806 |
for the error page extension. |
|
2807 |
||
2808 |
\inmodule QtWebKit |
|
2809 |
||
2810 |
The ErrorPageExtensionOption class holds the \a url for which an error occoured as well as |
|
2811 |
the associated \a frame. |
|
2812 |
||
2813 |
The error itself is reported by an error \a domain, the \a error code as well as \a errorString. |
|
2814 |
||
2815 |
\sa QWebPage::ErrorPageExtensionReturn |
|
2816 |
*/ |
|
2817 |
||
2818 |
/*! |
|
2819 |
\class QWebPage::ErrorPageExtensionReturn |
|
2820 |
\since 4.6 |
|
2821 |
\brief The ErrorPageExtensionReturn describes the error page, which will be shown for the |
|
2822 |
frame for which the error occured. |
|
2823 |
||
2824 |
\inmodule QtWebKit |
|
2825 |
||
2826 |
The ErrorPageExtensionReturn class holds the data needed for creating an error page. Some are |
|
2827 |
optional such as \a contentType, which defaults to "text/html", as well as the \a encoding, which |
|
2828 |
is assumed to be UTF-8 if not indicated otherwise. |
|
2829 |
||
2830 |
The error page is stored in the \a content byte array, as HTML content. In order to convert a |
|
2831 |
QString to a byte array, the QString::toUtf8() method can be used. |
|
2832 |
||
2833 |
External objects such as stylesheets or images referenced in the HTML are located relative to |
|
2834 |
\a baseUrl. |
|
2835 |
||
2836 |
\sa QWebPage::ErrorPageExtensionOption, QString::toUtf8() |
|
2837 |
*/ |
|
2838 |
||
2839 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2840 |
\fn QWebPage::ErrorPageExtensionReturn::ErrorPageExtensionReturn() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2841 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2842 |
Constructs a new error page object. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2843 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2844 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2845 |
/*! |
0 | 2846 |
\class QWebPage::ChooseMultipleFilesExtensionOption |
2847 |
\since 4.5 |
|
2848 |
\brief The ChooseMultipleFilesExtensionOption class describes the option |
|
2849 |
for the multiple files selection extension. |
|
2850 |
||
2851 |
\inmodule QtWebKit |
|
2852 |
||
2853 |
The ChooseMultipleFilesExtensionOption class holds the frame originating the request |
|
2854 |
and the suggested filenames which might be provided. |
|
2855 |
||
2856 |
\sa QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn |
|
2857 |
*/ |
|
2858 |
||
2859 |
/*! |
|
2860 |
\class QWebPage::ChooseMultipleFilesExtensionReturn |
|
2861 |
\since 4.5 |
|
2862 |
\brief The ChooseMultipleFilesExtensionReturn describes the return value |
|
2863 |
for the multiple files selection extension. |
|
2864 |
||
2865 |
\inmodule QtWebKit |
|
2866 |
||
2867 |
The ChooseMultipleFilesExtensionReturn class holds the filenames selected by the user |
|
2868 |
when the extension is invoked. |
|
2869 |
||
2870 |
\sa QWebPage::ChooseMultipleFilesExtensionOption |
|
2871 |
*/ |
|
2872 |
||
2873 |
/*! |
|
2874 |
This virtual function can be reimplemented in a QWebPage subclass to provide support for extensions. The \a option |
|
2875 |
argument is provided as input to the extension; the output results can be stored in \a output. |
|
2876 |
||
2877 |
The behavior of this function is determined by \a extension. |
|
2878 |
||
2879 |
You can call supportsExtension() to check if an extension is supported by the page. |
|
2880 |
||
2881 |
Returns true if the extension was called successfully; otherwise returns false. |
|
2882 |
||
2883 |
\sa supportsExtension(), Extension |
|
2884 |
*/ |
|
2885 |
bool QWebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) |
|
2886 |
{ |
|
2887 |
#ifndef QT_NO_FILEDIALOG |
|
2888 |
if (extension == ChooseMultipleFilesExtension) { |
|
2889 |
// FIXME: do not ignore suggestedFiles |
|
2890 |
QStringList suggestedFiles = static_cast<const ChooseMultipleFilesExtensionOption*>(option)->suggestedFileNames; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2891 |
QStringList names = QFileDialog::getOpenFileNames(view(), QString::null); |
0 | 2892 |
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names; |
2893 |
return true; |
|
2894 |
} |
|
2895 |
#endif |
|
2896 |
||
2897 |
return false; |
|
2898 |
} |
|
2899 |
||
2900 |
/*! |
|
2901 |
This virtual function returns true if the web page supports \a extension; otherwise false is returned. |
|
2902 |
||
2903 |
\sa extension() |
|
2904 |
*/ |
|
2905 |
bool QWebPage::supportsExtension(Extension extension) const |
|
2906 |
{ |
|
2907 |
#ifndef QT_NO_FILEDIALOG |
|
2908 |
return extension == ChooseMultipleFilesExtension; |
|
2909 |
#else |
|
2910 |
Q_UNUSED(extension); |
|
2911 |
return false; |
|
2912 |
#endif |
|
2913 |
} |
|
2914 |
||
2915 |
/*! |
|
2916 |
Finds the specified string, \a subString, in the page, using the given \a options. |
|
2917 |
||
2918 |
If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences |
|
2919 |
that exist in the page. All subsequent calls will extend the highlight, rather than |
|
2920 |
replace it, with occurrences of the new string. |
|
2921 |
||
2922 |
If the HighlightAllOccurrences flag is not passed, the function will select an occurrence |
|
2923 |
and all subsequent calls will replace the current occurrence with the next one. |
|
2924 |
||
2925 |
To clear the selection, just pass an empty string. |
|
2926 |
||
2927 |
Returns true if \a subString was found; otherwise returns false. |
|
2928 |
*/ |
|
2929 |
bool QWebPage::findText(const QString &subString, FindFlags options) |
|
2930 |
{ |
|
2931 |
::TextCaseSensitivity caseSensitivity = ::TextCaseInsensitive; |
|
2932 |
if (options & FindCaseSensitively) |
|
2933 |
caseSensitivity = ::TextCaseSensitive; |
|
2934 |
||
2935 |
if (options & HighlightAllOccurrences) { |
|
2936 |
if (subString.isEmpty()) { |
|
2937 |
d->page->unmarkAllTextMatches(); |
|
2938 |
return true; |
|
2939 |
} else |
|
2940 |
return d->page->markAllMatchesForText(subString, caseSensitivity, true, 0); |
|
2941 |
} else { |
|
2942 |
::FindDirection direction = ::FindDirectionForward; |
|
2943 |
if (options & FindBackward) |
|
2944 |
direction = ::FindDirectionBackward; |
|
2945 |
||
2946 |
const bool shouldWrap = options & FindWrapsAroundDocument; |
|
2947 |
||
2948 |
return d->page->findString(subString, caseSensitivity, direction, shouldWrap); |
|
2949 |
} |
|
2950 |
} |
|
2951 |
||
2952 |
/*! |
|
2953 |
Returns a pointer to the page's settings object. |
|
2954 |
||
2955 |
\sa QWebSettings::globalSettings() |
|
2956 |
*/ |
|
2957 |
QWebSettings *QWebPage::settings() const |
|
2958 |
{ |
|
2959 |
return d->settings; |
|
2960 |
} |
|
2961 |
||
2962 |
/*! |
|
2963 |
This function is called when the web content requests a file name, for example |
|
2964 |
as a result of the user clicking on a "file upload" button in a HTML form. |
|
2965 |
||
2966 |
A suggested filename may be provided in \a suggestedFile. The frame originating the |
|
2967 |
request is provided as \a parentFrame. |
|
2968 |
*/ |
|
2969 |
QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFile) |
|
2970 |
{ |
|
2971 |
Q_UNUSED(parentFrame) |
|
2972 |
#ifndef QT_NO_FILEDIALOG |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2973 |
return QFileDialog::getOpenFileName(view(), QString::null, suggestedFile); |
0 | 2974 |
#else |
2975 |
return QString::null; |
|
2976 |
#endif |
|
2977 |
} |
|
2978 |
||
2979 |
#if QT_VERSION < 0x040400 && !defined qdoc |
|
2980 |
||
2981 |
void QWebPage::setNetworkInterface(QWebNetworkInterface *interface) |
|
2982 |
{ |
|
2983 |
d->networkInterface = interface; |
|
2984 |
} |
|
2985 |
||
2986 |
QWebNetworkInterface *QWebPage::networkInterface() const |
|
2987 |
{ |
|
2988 |
if (d->networkInterface) |
|
2989 |
return d->networkInterface; |
|
2990 |
else |
|
2991 |
return QWebNetworkInterface::defaultInterface(); |
|
2992 |
} |
|
2993 |
||
2994 |
#ifndef QT_NO_NETWORKPROXY |
|
2995 |
void QWebPage::setNetworkProxy(const QNetworkProxy& proxy) |
|
2996 |
{ |
|
2997 |
d->networkProxy = proxy; |
|
2998 |
} |
|
2999 |
||
3000 |
QNetworkProxy QWebPage::networkProxy() const |
|
3001 |
{ |
|
3002 |
return d->networkProxy; |
|
3003 |
} |
|
3004 |
#endif |
|
3005 |
||
3006 |
#else |
|
3007 |
||
3008 |
/*! |
|
3009 |
Sets the QNetworkAccessManager \a manager responsible for serving network requests for this |
|
3010 |
QWebPage. |
|
3011 |
||
3012 |
\note It is currently not supported to change the network access manager after the |
|
3013 |
QWebPage has used it. The results of doing this are undefined. |
|
3014 |
||
3015 |
\sa networkAccessManager() |
|
3016 |
*/ |
|
3017 |
void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager) |
|
3018 |
{ |
|
3019 |
if (manager == d->networkManager) |
|
3020 |
return; |
|
3021 |
if (d->networkManager && d->networkManager->parent() == this) |
|
3022 |
delete d->networkManager; |
|
3023 |
d->networkManager = manager; |
|
3024 |
} |
|
3025 |
||
3026 |
/*! |
|
3027 |
Returns the QNetworkAccessManager that is responsible for serving network |
|
3028 |
requests for this QWebPage. |
|
3029 |
||
3030 |
\sa setNetworkAccessManager() |
|
3031 |
*/ |
|
3032 |
QNetworkAccessManager *QWebPage::networkAccessManager() const |
|
3033 |
{ |
|
3034 |
if (!d->networkManager) { |
|
3035 |
QWebPage *that = const_cast<QWebPage *>(this); |
|
3036 |
that->d->networkManager = new QNetworkAccessManager(that); |
|
3037 |
} |
|
3038 |
return d->networkManager; |
|
3039 |
} |
|
3040 |
||
3041 |
#endif |
|
3042 |
||
3043 |
/*! |
|
3044 |
Sets the QWebPluginFactory \a factory responsible for creating plugins embedded into this |
|
3045 |
QWebPage. |
|
3046 |
||
3047 |
Note: The plugin factory is only used if the QWebSettings::PluginsEnabled attribute is enabled. |
|
3048 |
||
3049 |
\sa pluginFactory() |
|
3050 |
*/ |
|
3051 |
void QWebPage::setPluginFactory(QWebPluginFactory *factory) |
|
3052 |
{ |
|
3053 |
d->pluginFactory = factory; |
|
3054 |
} |
|
3055 |
||
3056 |
/*! |
|
3057 |
Returns the QWebPluginFactory that is responsible for creating plugins embedded into |
|
3058 |
this QWebPage. If no plugin factory is installed a null pointer is returned. |
|
3059 |
||
3060 |
\sa setPluginFactory() |
|
3061 |
*/ |
|
3062 |
QWebPluginFactory *QWebPage::pluginFactory() const |
|
3063 |
{ |
|
3064 |
return d->pluginFactory; |
|
3065 |
} |
|
3066 |
||
3067 |
/*! |
|
3068 |
This function is called when a user agent for HTTP requests is needed. You can reimplement this |
|
3069 |
function to dynamically return different user agents for different URLs, based on the \a url parameter. |
|
3070 |
||
3071 |
The default implementation returns the following value: |
|
3072 |
||
3073 |
"Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%" |
|
3074 |
||
3075 |
In this string the following values are replaced at run-time: |
|
3076 |
\list |
|
3077 |
\o %Platform% and %Subplatform% are expanded to the windowing system and the operation system. |
|
3078 |
\o %Security% expands to U if SSL is enabled, otherwise N. SSL is enabled if QSslSocket::supportsSsl() returns true. |
|
3079 |
\o %Locale% is replaced with QLocale::name(). The locale is determined from the view of the QWebPage. If no view is set on the QWebPage, |
|
3080 |
then a default constructed QLocale is used instead. |
|
3081 |
\o %WebKitVersion% is the version of WebKit the application was compiled against. |
|
3082 |
\o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version. |
|
3083 |
\endlist |
|
3084 |
*/ |
|
3085 |
QString QWebPage::userAgentForUrl(const QUrl& url) const |
|
3086 |
{ |
|
3087 |
Q_UNUSED(url) |
|
3088 |
QString ua = QLatin1String("Mozilla/5.0 (" |
|
3089 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3090 |
// Platform |
0 | 3091 |
#ifdef Q_WS_MAC |
3092 |
"Macintosh" |
|
3093 |
#elif defined Q_WS_QWS |
|
3094 |
"QtEmbedded" |
|
3095 |
#elif defined Q_WS_WIN |
|
3096 |
"Windows" |
|
3097 |
#elif defined Q_WS_X11 |
|
3098 |
"X11" |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3099 |
#elif defined Q_OS_SYMBIAN |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3100 |
"SymbianOS" |
0 | 3101 |
#else |
3102 |
"Unknown" |
|
3103 |
#endif |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3104 |
// Placeholder for Platform Version |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3105 |
"%1; " |
0 | 3106 |
|
3107 |
// Placeholder for security strength (N or U) |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3108 |
"%2; " |
0 | 3109 |
|
3110 |
// Subplatform" |
|
3111 |
#ifdef Q_OS_AIX |
|
3112 |
"AIX" |
|
3113 |
#elif defined Q_OS_WIN32 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3114 |
"%3" |
0 | 3115 |
#elif defined Q_OS_DARWIN |
3116 |
#ifdef __i386__ || __x86_64__ |
|
3117 |
"Intel Mac OS X" |
|
3118 |
#else |
|
3119 |
"PPC Mac OS X" |
|
3120 |
#endif |
|
3121 |
||
3122 |
#elif defined Q_OS_BSDI |
|
3123 |
"BSD" |
|
3124 |
#elif defined Q_OS_BSD4 |
|
3125 |
"BSD Four" |
|
3126 |
#elif defined Q_OS_CYGWIN |
|
3127 |
"Cygwin" |
|
3128 |
#elif defined Q_OS_DGUX |
|
3129 |
"DG/UX" |
|
3130 |
#elif defined Q_OS_DYNIX |
|
3131 |
"DYNIX/ptx" |
|
3132 |
#elif defined Q_OS_FREEBSD |
|
3133 |
"FreeBSD" |
|
3134 |
#elif defined Q_OS_HPUX |
|
3135 |
"HP-UX" |
|
3136 |
#elif defined Q_OS_HURD |
|
3137 |
"GNU Hurd" |
|
3138 |
#elif defined Q_OS_IRIX |
|
3139 |
"SGI Irix" |
|
3140 |
#elif defined Q_OS_LINUX |
|
3141 |
"Linux" |
|
3142 |
#elif defined Q_OS_LYNX |
|
3143 |
"LynxOS" |
|
3144 |
#elif defined Q_OS_NETBSD |
|
3145 |
"NetBSD" |
|
3146 |
#elif defined Q_OS_OS2 |
|
3147 |
"OS/2" |
|
3148 |
#elif defined Q_OS_OPENBSD |
|
3149 |
"OpenBSD" |
|
3150 |
#elif defined Q_OS_OS2EMX |
|
3151 |
"OS/2" |
|
3152 |
#elif defined Q_OS_OSF |
|
3153 |
"HP Tru64 UNIX" |
|
3154 |
#elif defined Q_OS_QNX6 |
|
3155 |
"QNX RTP Six" |
|
3156 |
#elif defined Q_OS_QNX |
|
3157 |
"QNX" |
|
3158 |
#elif defined Q_OS_RELIANT |
|
3159 |
"Reliant UNIX" |
|
3160 |
#elif defined Q_OS_SCO |
|
3161 |
"SCO OpenServer" |
|
3162 |
#elif defined Q_OS_SOLARIS |
|
3163 |
"Sun Solaris" |
|
3164 |
#elif defined Q_OS_ULTRIX |
|
3165 |
"DEC Ultrix" |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3166 |
#elif defined Q_WS_S60 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3167 |
"Series60" |
0 | 3168 |
#elif defined Q_OS_UNIX |
3169 |
"UNIX BSD/SYSV system" |
|
3170 |
#elif defined Q_OS_UNIXWARE |
|
3171 |
"UnixWare Seven, Open UNIX Eight" |
|
3172 |
#else |
|
3173 |
"Unknown" |
|
3174 |
#endif |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3175 |
// Placeholder for SubPlatform Version |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3176 |
"%4; "); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3177 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3178 |
// Platform Version |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3179 |
QString osVer; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3180 |
#ifdef Q_OS_SYMBIAN |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3181 |
QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3182 |
switch (symbianVersion) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3183 |
case QSysInfo::SV_9_2: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3184 |
osVer = "/9.2"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3185 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3186 |
case QSysInfo::SV_9_3: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3187 |
osVer = "/9.3"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3188 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3189 |
case QSysInfo::SV_9_4: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3190 |
osVer = "/9.4"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3191 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3192 |
default: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3193 |
osVer = "Unknown"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3194 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3195 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3196 |
ua = ua.arg(osVer); |
0 | 3197 |
|
3198 |
QChar securityStrength(QLatin1Char('N')); |
|
3199 |
#if !defined(QT_NO_OPENSSL) |
|
3200 |
// we could check QSslSocket::supportsSsl() here, but this makes |
|
3201 |
// OpenSSL, certificates etc being loaded in all cases were QWebPage |
|
3202 |
// is used. This loading is not needed for non-https. |
|
3203 |
securityStrength = QLatin1Char('U'); |
|
3204 |
// this may lead to a false positive: We indicate SSL since it is |
|
3205 |
// compiled in even though supportsSsl() might return false |
|
3206 |
#endif |
|
3207 |
ua = ua.arg(securityStrength); |
|
3208 |
||
3209 |
#if defined Q_OS_WIN32 |
|
3210 |
QString ver; |
|
3211 |
switch (QSysInfo::WindowsVersion) { |
|
3212 |
case QSysInfo::WV_32s: |
|
3213 |
ver = "Windows 3.1"; |
|
3214 |
break; |
|
3215 |
case QSysInfo::WV_95: |
|
3216 |
ver = "Windows 95"; |
|
3217 |
break; |
|
3218 |
case QSysInfo::WV_98: |
|
3219 |
ver = "Windows 98"; |
|
3220 |
break; |
|
3221 |
case QSysInfo::WV_Me: |
|
3222 |
ver = "Windows 98; Win 9x 4.90"; |
|
3223 |
break; |
|
3224 |
case QSysInfo::WV_NT: |
|
3225 |
ver = "WinNT4.0"; |
|
3226 |
break; |
|
3227 |
case QSysInfo::WV_2000: |
|
3228 |
ver = "Windows NT 5.0"; |
|
3229 |
break; |
|
3230 |
case QSysInfo::WV_XP: |
|
3231 |
ver = "Windows NT 5.1"; |
|
3232 |
break; |
|
3233 |
case QSysInfo::WV_2003: |
|
3234 |
ver = "Windows NT 5.2"; |
|
3235 |
break; |
|
3236 |
case QSysInfo::WV_VISTA: |
|
3237 |
ver = "Windows NT 6.0"; |
|
3238 |
break; |
|
3239 |
#if QT_VERSION > 0x040500 |
|
3240 |
case QSysInfo::WV_WINDOWS7: |
|
3241 |
ver = "Windows NT 6.1"; |
|
3242 |
break; |
|
3243 |
#endif |
|
3244 |
case QSysInfo::WV_CE: |
|
3245 |
ver = "Windows CE"; |
|
3246 |
break; |
|
3247 |
case QSysInfo::WV_CENET: |
|
3248 |
ver = "Windows CE .NET"; |
|
3249 |
break; |
|
3250 |
case QSysInfo::WV_CE_5: |
|
3251 |
ver = "Windows CE 5.x"; |
|
3252 |
break; |
|
3253 |
case QSysInfo::WV_CE_6: |
|
3254 |
ver = "Windows CE 6.x"; |
|
3255 |
break; |
|
3256 |
} |
|
3257 |
ua = QString(ua).arg(ver); |
|
3258 |
#endif |
|
3259 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3260 |
// SubPlatform Version |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3261 |
QString subPlatformVer; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3262 |
#ifdef Q_OS_SYMBIAN |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3263 |
QSysInfo::S60Version s60Version = QSysInfo::s60Version(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3264 |
switch (s60Version) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3265 |
case QSysInfo::SV_S60_3_1: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3266 |
subPlatformVer = "/3.1"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3267 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3268 |
case QSysInfo::SV_S60_3_2: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3269 |
subPlatformVer = "/3.2"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3270 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3271 |
case QSysInfo::SV_S60_5_0: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3272 |
subPlatformVer = "/5.0"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3273 |
break; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3274 |
default: |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3275 |
subPlatformVer = " Unknown"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3276 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3277 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3278 |
ua = ua.arg(subPlatformVer); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3279 |
|
0 | 3280 |
// Language |
3281 |
QLocale locale; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3282 |
if (view()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3283 |
locale = view()->locale(); |
0 | 3284 |
QString name = locale.name(); |
3285 |
name[2] = QLatin1Char('-'); |
|
3286 |
ua.append(name); |
|
3287 |
ua.append(QLatin1String(") ")); |
|
3288 |
||
3289 |
// webkit/qt version |
|
3290 |
ua.append(QString(QLatin1String("AppleWebKit/%1 (KHTML, like Gecko) ")) |
|
3291 |
.arg(QString(qWebKitVersion()))); |
|
3292 |
||
3293 |
// Application name/version |
|
3294 |
QString appName = QCoreApplication::applicationName(); |
|
3295 |
if (!appName.isEmpty()) { |
|
3296 |
ua.append(appName); |
|
3297 |
#if QT_VERSION >= 0x040400 |
|
3298 |
QString appVer = QCoreApplication::applicationVersion(); |
|
3299 |
if (!appVer.isEmpty()) |
|
3300 |
ua.append(QLatin1Char('/') + appVer); |
|
3301 |
#endif |
|
3302 |
} else { |
|
3303 |
// Qt version |
|
3304 |
ua.append(QLatin1String("Qt/")); |
|
3305 |
ua.append(QLatin1String(qVersion())); |
|
3306 |
} |
|
3307 |
||
3308 |
ua.append(QString(QLatin1String(" Safari/%1")) |
|
3309 |
.arg(qWebKitVersion())); |
|
3310 |
||
3311 |
return ua; |
|
3312 |
} |
|
3313 |
||
3314 |
||
3315 |
void QWebPagePrivate::_q_onLoadProgressChanged(int) |
|
3316 |
{ |
|
3317 |
m_totalBytes = page->progress()->totalPageAndResourceBytesToLoad(); |
|
3318 |
m_bytesReceived = page->progress()->totalBytesReceived(); |
|
3319 |
} |
|
3320 |
||
3321 |
||
3322 |
/*! |
|
3323 |
Returns the total number of bytes that were received from the network to render the current page, |
|
3324 |
including extra content such as embedded images. |
|
3325 |
||
3326 |
\sa bytesReceived() |
|
3327 |
*/ |
|
3328 |
quint64 QWebPage::totalBytes() const |
|
3329 |
{ |
|
3330 |
return d->m_totalBytes; |
|
3331 |
} |
|
3332 |
||
3333 |
||
3334 |
/*! |
|
3335 |
Returns the number of bytes that were received from the network to render the current page. |
|
3336 |
||
3337 |
\sa totalBytes() |
|
3338 |
*/ |
|
3339 |
quint64 QWebPage::bytesReceived() const |
|
3340 |
{ |
|
3341 |
return d->m_bytesReceived; |
|
3342 |
} |
|
3343 |
||
3344 |
/*! |
|
3345 |
\fn void QWebPage::loadStarted() |
|
3346 |
||
3347 |
This signal is emitted when a new load of the page is started. |
|
3348 |
||
3349 |
\sa loadFinished() |
|
3350 |
*/ |
|
3351 |
||
3352 |
/*! |
|
3353 |
\fn void QWebPage::loadProgress(int progress) |
|
3354 |
||
3355 |
This signal is emitted when the global progress status changes. |
|
3356 |
The current value is provided by \a progress and scales from 0 to 100, |
|
3357 |
which is the default range of QProgressBar. |
|
3358 |
It accumulates changes from all the child frames. |
|
3359 |
||
3360 |
\sa bytesReceived() |
|
3361 |
*/ |
|
3362 |
||
3363 |
/*! |
|
3364 |
\fn void QWebPage::loadFinished(bool ok) |
|
3365 |
||
3366 |
This signal is emitted when a load of the page is finished. |
|
3367 |
\a ok will indicate whether the load was successful or any error occurred. |
|
3368 |
||
3369 |
\sa loadStarted() |
|
3370 |
*/ |
|
3371 |
||
3372 |
/*! |
|
3373 |
\fn void QWebPage::linkHovered(const QString &link, const QString &title, const QString &textContent) |
|
3374 |
||
3375 |
This signal is emitted when the mouse hovers over a link. |
|
3376 |
||
3377 |
\a link contains the link url. |
|
3378 |
\a title is the link element's title, if it is specified in the markup. |
|
3379 |
\a textContent provides text within the link element, e.g., text inside an HTML anchor tag. |
|
3380 |
||
3381 |
When the mouse leaves the link element the signal is emitted with empty parameters. |
|
3382 |
||
3383 |
\sa linkClicked() |
|
3384 |
*/ |
|
3385 |
||
3386 |
/*! |
|
3387 |
\fn void QWebPage::statusBarMessage(const QString& text) |
|
3388 |
||
3389 |
This signal is emitted when the statusbar \a text is changed by the page. |
|
3390 |
*/ |
|
3391 |
||
3392 |
/*! |
|
3393 |
\fn void QWebPage::frameCreated(QWebFrame *frame) |
|
3394 |
||
3395 |
This signal is emitted whenever the page creates a new \a frame. |
|
3396 |
*/ |
|
3397 |
||
3398 |
/*! |
|
3399 |
\fn void QWebPage::selectionChanged() |
|
3400 |
||
3401 |
This signal is emitted whenever the selection changes. |
|
3402 |
||
3403 |
\sa selectedText() |
|
3404 |
*/ |
|
3405 |
||
3406 |
/*! |
|
3407 |
\fn void QWebPage::contentsChanged() |
|
3408 |
\since 4.5 |
|
3409 |
||
3410 |
This signal is emitted whenever the text in form elements changes |
|
3411 |
as well as other editable content. |
|
3412 |
||
3413 |
\sa contentEditable, QWebFrame::toHtml(), QWebFrame::toPlainText() |
|
3414 |
*/ |
|
3415 |
||
3416 |
/*! |
|
3417 |
\fn void QWebPage::geometryChangeRequested(const QRect& geom) |
|
3418 |
||
3419 |
This signal is emitted whenever the document wants to change the position and size of the |
|
3420 |
page to \a geom. This can happen for example through JavaScript. |
|
3421 |
*/ |
|
3422 |
||
3423 |
/*! |
|
3424 |
\fn void QWebPage::repaintRequested(const QRect& dirtyRect) |
|
3425 |
||
3426 |
This signal is emitted whenever this QWebPage should be updated and no view was set. |
|
3427 |
\a dirtyRect contains the area that needs to be updated. To paint the QWebPage get |
|
3428 |
the mainFrame() and call the render(QPainter*, const QRegion&) method with the |
|
3429 |
\a dirtyRect as the second parameter. |
|
3430 |
||
3431 |
\sa mainFrame() |
|
3432 |
\sa view() |
|
3433 |
*/ |
|
3434 |
||
3435 |
/*! |
|
3436 |
\fn void QWebPage::scrollRequested(int dx, int dy, const QRect& rectToScroll) |
|
3437 |
||
3438 |
This signal is emitted whenever the content given by \a rectToScroll needs |
|
3439 |
to be scrolled \a dx and \a dy downwards and no view was set. |
|
3440 |
||
3441 |
\sa view() |
|
3442 |
*/ |
|
3443 |
||
3444 |
/*! |
|
3445 |
\fn void QWebPage::windowCloseRequested() |
|
3446 |
||
3447 |
This signal is emitted whenever the page requests the web browser window to be closed, |
|
3448 |
for example through the JavaScript \c{window.close()} call. |
|
3449 |
*/ |
|
3450 |
||
3451 |
/*! |
|
3452 |
\fn void QWebPage::printRequested(QWebFrame *frame) |
|
3453 |
||
3454 |
This signal is emitted whenever the page requests the web browser to print \a frame, |
|
3455 |
for example through the JavaScript \c{window.print()} call. |
|
3456 |
||
3457 |
\sa QWebFrame::print(), QPrintPreviewDialog |
|
3458 |
*/ |
|
3459 |
||
3460 |
/*! |
|
3461 |
\fn void QWebPage::unsupportedContent(QNetworkReply *reply) |
|
3462 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3463 |
This signal is emitted when WebKit cannot handle a link the user navigated to. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3464 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3465 |
At signal emission time the meta-data of the QNetworkReply \a reply is available. |
0 | 3466 |
|
3467 |
\note This signal is only emitted if the forwardUnsupportedContent property is set to true. |
|
3468 |
||
3469 |
\sa downloadRequested() |
|
3470 |
*/ |
|
3471 |
||
3472 |
/*! |
|
3473 |
\fn void QWebPage::downloadRequested(const QNetworkRequest &request) |
|
3474 |
||
3475 |
This signal is emitted when the user decides to download a link. The url of |
|
3476 |
the link as well as additional meta-information is contained in \a request. |
|
3477 |
||
3478 |
\sa unsupportedContent() |
|
3479 |
*/ |
|
3480 |
||
3481 |
/*! |
|
3482 |
\fn void QWebPage::microFocusChanged() |
|
3483 |
||
3484 |
This signal is emitted when for example the position of the cursor in an editable form |
|
3485 |
element changes. It is used inform input methods about the new on-screen position where |
|
3486 |
the user is able to enter text. This signal is usually connected to QWidget's updateMicroFocus() |
|
3487 |
slot. |
|
3488 |
*/ |
|
3489 |
||
3490 |
/*! |
|
3491 |
\fn void QWebPage::linkClicked(const QUrl &url) |
|
3492 |
||
3493 |
This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy |
|
3494 |
property is set to delegate the link handling for the specified \a url. |
|
3495 |
||
3496 |
By default no links are delegated and are handled by QWebPage instead. |
|
3497 |
||
3498 |
\sa linkHovered() |
|
3499 |
*/ |
|
3500 |
||
3501 |
/*! |
|
3502 |
\fn void QWebPage::toolBarVisibilityChangeRequested(bool visible) |
|
3503 |
||
3504 |
This signal is emitted whenever the visibility of the toolbar in a web browser |
|
3505 |
window that hosts QWebPage should be changed to \a visible. |
|
3506 |
*/ |
|
3507 |
||
3508 |
/*! |
|
3509 |
\fn void QWebPage::statusBarVisibilityChangeRequested(bool visible) |
|
3510 |
||
3511 |
This signal is emitted whenever the visibility of the statusbar in a web browser |
|
3512 |
window that hosts QWebPage should be changed to \a visible. |
|
3513 |
*/ |
|
3514 |
||
3515 |
/*! |
|
3516 |
\fn void QWebPage::menuBarVisibilityChangeRequested(bool visible) |
|
3517 |
||
3518 |
This signal is emitted whenever the visibility of the menubar in a web browser |
|
3519 |
window that hosts QWebPage should be changed to \a visible. |
|
3520 |
*/ |
|
3521 |
||
3522 |
/*! |
|
3523 |
\fn void QWebPage::databaseQuotaExceeded(QWebFrame* frame, QString databaseName); |
|
3524 |
\since 4.5 |
|
3525 |
||
3526 |
This signal is emitted whenever the web site shown in \a frame is asking to store data |
|
3527 |
to the database \a databaseName and the quota allocated to that web site is exceeded. |
|
3528 |
*/ |
|
3529 |
||
3530 |
/*! |
|
3531 |
\since 4.5 |
|
3532 |
\fn void QWebPage::saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); |
|
3533 |
||
3534 |
This signal is emitted shortly before the history of navigated pages |
|
3535 |
in \a frame is changed, for example when navigating back in the history. |
|
3536 |
||
3537 |
The provided QWebHistoryItem, \a item, holds the history entry of the frame before |
|
3538 |
the change. |
|
3539 |
||
3540 |
A potential use-case for this signal is to store custom data in |
|
3541 |
the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData(). |
|
3542 |
*/ |
|
3543 |
||
3544 |
/*! |
|
3545 |
\since 4.5 |
|
3546 |
\fn void QWebPage::restoreFrameStateRequested(QWebFrame* frame); |
|
3547 |
||
3548 |
This signal is emitted when the load of \a frame is finished and the application may now update its state accordingly. |
|
3549 |
*/ |
|
3550 |
||
3551 |
/*! |
|
3552 |
\fn QWebPagePrivate* QWebPage::handle() const |
|
3553 |
\internal |
|
3554 |
*/ |
|
3555 |
||
3556 |
#include "moc_qwebpage.cpp" |