summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/qt/Api/qwebpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/qt/Api/qwebpage.cpp')
-rw-r--r--Source/WebKit/qt/Api/qwebpage.cpp178
1 files changed, 76 insertions, 102 deletions
diff --git a/Source/WebKit/qt/Api/qwebpage.cpp b/Source/WebKit/qt/Api/qwebpage.cpp
index 075756d..2f51e6f 100644
--- a/Source/WebKit/qt/Api/qwebpage.cpp
+++ b/Source/WebKit/qt/Api/qwebpage.cpp
@@ -62,6 +62,10 @@
#include "FrameLoaderClientQt.h"
#include "FrameTree.h"
#include "FrameView.h"
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+#include "GeolocationClientMock.h"
+#include "GeolocationClientQt.h"
+#endif // CLIENT_BASED_GEOLOCATION
#include "GeolocationPermissionClientQt.h"
#include "HTMLFormElement.h"
#include "HTMLFrameOwnerElement.h"
@@ -100,6 +104,9 @@
#include "Scrollbar.h"
#include "SecurityOrigin.h"
#include "Settings.h"
+#if defined Q_OS_WIN32
+#include "SystemInfo.h"
+#endif // Q_OS_WIN32
#include "TextIterator.h"
#include "WebPlatformStrategies.h"
#include "WindowFeatures.h"
@@ -119,7 +126,6 @@
#include <QFileDialog>
#include <QHttpRequestHeader>
#include <QInputDialog>
-#include <QLocale>
#include <QMessageBox>
#include <QNetworkProxy>
#include <QUndoStack>
@@ -137,7 +143,9 @@
#if defined(Q_WS_X11)
#include <QX11Info>
#endif
-
+#if ENABLE(QT_USERAGENT_DEVICEMODEL)
+#include <qsysteminfo.h>
+#endif
using namespace WebCore;
@@ -297,7 +305,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
, currentContextMenu(0)
#endif
, settings(0)
- , editable(false)
, useFixedLayout(false)
, pluginFactory(0)
, inspectorFrontend(0)
@@ -308,9 +315,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
ScriptController::initializeThreading();
WTF::initializeMainThread();
WebCore::SecurityOrigin::setLocalLoadPolicy(WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData);
-#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
- WebCore::Font::setCodePath(WebCore::Font::Complex);
-#endif
WebPlatformStrategies::initialize();
@@ -324,8 +328,19 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
pageClients.deviceOrientationClient = new DeviceOrientationClientQt(q);
pageClients.deviceMotionClient = new DeviceMotionClientQt(q);
#endif
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ if (QWebPagePrivate::drtRun)
+ pageClients.geolocationClient = new GeolocationClientMock();
+ else
+ pageClients.geolocationClient = new GeolocationClientQt(q);
+#endif
page = new Page(pageClients);
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ // In case running in DumpRenderTree mode set the controller to mock provider.
+ if (QWebPagePrivate::drtRun)
+ static_cast<GeolocationClientMock*>(pageClients.geolocationClient)->setController(page->geolocationController());
+#endif
settings = new QWebSettings(page->settings());
history.d = new QWebHistoryPrivate(static_cast<WebCore::BackForwardListImpl*>(page->backForwardList()));
@@ -732,7 +747,7 @@ void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button)
WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame();
if (button == Qt::LeftButton) {
if (focusFrame && (focusFrame->editor()->canCopy() || focusFrame->editor()->canDHTMLCopy())) {
- focusFrame->editor()->copy();
+ Pasteboard::generalPasteboard()->writeSelection(focusFrame->editor()->selectedRange().get(), focusFrame->editor()->canSmartCopyOrDelete(), focusFrame);
ev->setAccepted(true);
}
} else if (button == Qt::MidButton) {
@@ -964,8 +979,7 @@ void QWebPagePrivate::dragEnterEvent(T* ev)
QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData));
ev->setDropAction(action);
- if (action != Qt::IgnoreAction)
- ev->acceptProposedAction();
+ ev->acceptProposedAction();
#endif
}
@@ -1153,7 +1167,7 @@ void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* ev
QString p = q->property("_q_RepaintThrottlingPreset").toString();
for(int i = 0; i < sizeof(presets) / sizeof(presets[0]); i++) {
- if(p == presets[i].name) {
+ if (p == QLatin1String(presets[i].name)) {
FrameView::setRepaintThrottlingDeferredRepaintDelay(
presets[i].deferredRepaintDelay);
FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(
@@ -1204,6 +1218,9 @@ void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* ev
else if (event->propertyName() == "_q_webInspectorServerPort") {
InspectorServerQt* inspectorServer = InspectorServerQt::server();
inspectorServer->listen(inspectorServerPort());
+ } else if (event->propertyName() == "_q_deadDecodedDataDeletionInterval") {
+ double interval = q->property("_q_deadDecodedDataDeletionInterval").toDouble();
+ memoryCache()->setDeadDecodedDataDeletionInterval(interval);
}
}
#endif
@@ -2055,7 +2072,7 @@ void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber,
// Catch plugin logDestroy message for LayoutTests/plugins/open-and-close-window-with-plugin.html
// At this point DRT's WebPage has already been destroyed
if (QWebPagePrivate::drtRun) {
- if (message == "PLUGIN: NPP_Destroy")
+ if (message == QLatin1String("PLUGIN: NPP_Destroy"))
fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, message.toUtf8().constData());
}
}
@@ -2431,7 +2448,7 @@ void QWebPage::setViewportSize(const QSize &size) const
QWebFrame *frame = mainFrame();
if (frame->d->frame && frame->d->frame->view()) {
WebCore::FrameView* view = frame->d->frame->view();
- view->setFrameRect(QRect(QPoint(0, 0), size));
+ view->resize(size);
view->adjustViewSize();
}
}
@@ -2525,7 +2542,7 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
result.m_minimumScaleFactor = conf.minimumScale;
result.m_maximumScaleFactor = conf.maximumScale;
result.m_devicePixelRatio = conf.devicePixelRatio;
- result.m_isUserScalable = conf.userScalable;
+ result.m_isUserScalable = static_cast<bool>(conf.userScalable);
d->pixelRatio = conf.devicePixelRatio;
@@ -3153,8 +3170,8 @@ bool QWebPage::focusNextPrevChild(bool next)
*/
void QWebPage::setContentEditable(bool editable)
{
- if (d->editable != editable) {
- d->editable = editable;
+ if (isContentEditable() != editable) {
+ d->page->setEditable(editable);
d->page->setTabKeyCyclesThroughElements(!editable);
if (d->mainFrame) {
WebCore::Frame* frame = d->mainFrame->d->frame;
@@ -3171,7 +3188,7 @@ void QWebPage::setContentEditable(bool editable)
bool QWebPage::isContentEditable() const
{
- return d->editable;
+ return d->page->isEditable();
}
/*!
@@ -3676,16 +3693,15 @@ QWebPluginFactory *QWebPage::pluginFactory() const
The default implementation returns the following value:
- "Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"
+ "Mozilla/5.0 (%Platform%%Security%%Subplatform%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"
On mobile platforms such as Symbian S60 and Maemo, "Mobile Safari" is used instead of "Safari".
In this string the following values are replaced at run-time:
\list
- \o %Platform% and %Subplatform% are expanded to the windowing system and the operation system.
- \o %Security% expands to U if SSL is enabled, otherwise N. SSL is enabled if QSslSocket::supportsSsl() returns true.
- \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,
- then a default constructed QLocale is used instead.
+ \o %Platform% expands to the windowing system followed by "; " if it is not Windows (e.g. "X11; ").
+ \o %Security% expands to "N; " if SSL is disabled.
+ \o %Subplatform% expands to the operating system version (e.g. "Windows NT 6.1" or "Intel Mac OS X 10.5").
\o %WebKitVersion% is the version of WebKit the application was compiled against.
\o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version.
\endlist
@@ -3704,17 +3720,21 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
// Platform
#ifdef Q_WS_MAC
- "Macintosh"
+ "Macintosh; "
#elif defined Q_WS_QWS
- "QtEmbedded"
+ "QtEmbedded; "
+#elif defined Q_WS_MAEMO_5
+ "Maemo"
+#elif defined Q_WS_MAEMO_6
+ "MeeGo"
#elif defined Q_WS_WIN
- "Windows"
+ // Nothing
#elif defined Q_WS_X11
- "X11"
+ "X11; "
#elif defined Q_OS_SYMBIAN
"Symbian"
#else
- "Unknown"
+ "Unknown; "
#endif
);
@@ -3722,38 +3742,31 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();
switch (symbianVersion) {
case QSysInfo::SV_9_2:
- firstPartTemp += QString::fromLatin1("OS/9.2");
+ firstPartTemp += QString::fromLatin1("OS/9.2; ");
break;
case QSysInfo::SV_9_3:
- firstPartTemp += QString::fromLatin1("OS/9.3");
+ firstPartTemp += QString::fromLatin1("OS/9.3; ");
break;
case QSysInfo::SV_9_4:
- firstPartTemp += QString::fromLatin1("OS/9.4");
+ firstPartTemp += QString::fromLatin1("OS/9.4; ");
break;
case QSysInfo::SV_SF_2:
- firstPartTemp += QString::fromLatin1("/2");
+ firstPartTemp += QString::fromLatin1("/2; ");
break;
case QSysInfo::SV_SF_3:
- firstPartTemp += QString::fromLatin1("/3");
+ firstPartTemp += QString::fromLatin1("/3; ");
break;
case QSysInfo::SV_SF_4:
- firstPartTemp += QString::fromLatin1("/4");
+ firstPartTemp += QString::fromLatin1("/4; ");
+ break;
default:
+ firstPartTemp += QString::fromLatin1("; ");
break;
}
#endif
- firstPartTemp += QString::fromLatin1("; ");
-
- // SSL support
-#if !defined(QT_NO_OPENSSL)
- // we could check QSslSocket::supportsSsl() here, but this makes
- // OpenSSL, certificates etc being loaded in all cases were QWebPage
- // is used. This loading is not needed for non-https.
- firstPartTemp += QString::fromLatin1("U; ");
- // this may lead to a false positive: We indicate SSL since it is
- // compiled in even though supportsSsl() might return false
-#else
+#if defined(QT_NO_OPENSSL)
+ // No SSL support
firstPartTemp += QString::fromLatin1("N; ");
#endif
@@ -3761,52 +3774,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
#ifdef Q_OS_AIX
firstPartTemp += QString::fromLatin1("AIX");
#elif defined Q_OS_WIN32
-
- switch (QSysInfo::WindowsVersion) {
- case QSysInfo::WV_32s:
- firstPartTemp += QString::fromLatin1("Windows 3.1");
- break;
- case QSysInfo::WV_95:
- firstPartTemp += QString::fromLatin1("Windows 95");
- break;
- case QSysInfo::WV_98:
- firstPartTemp += QString::fromLatin1("Windows 98");
- break;
- case QSysInfo::WV_Me:
- firstPartTemp += QString::fromLatin1("Windows 98; Win 9x 4.90");
- break;
- case QSysInfo::WV_NT:
- firstPartTemp += QString::fromLatin1("WinNT4.0");
- break;
- case QSysInfo::WV_2000:
- firstPartTemp += QString::fromLatin1("Windows NT 5.0");
- break;
- case QSysInfo::WV_XP:
- firstPartTemp += QString::fromLatin1("Windows NT 5.1");
- break;
- case QSysInfo::WV_2003:
- firstPartTemp += QString::fromLatin1("Windows NT 5.2");
- break;
- case QSysInfo::WV_VISTA:
- firstPartTemp += QString::fromLatin1("Windows NT 6.0");
- break;
- case QSysInfo::WV_WINDOWS7:
- firstPartTemp += QString::fromLatin1("Windows NT 6.1");
- break;
- case QSysInfo::WV_CE:
- firstPartTemp += QString::fromLatin1("Windows CE");
- break;
- case QSysInfo::WV_CENET:
- firstPartTemp += QString::fromLatin1("Windows CE .NET");
- break;
- case QSysInfo::WV_CE_5:
- firstPartTemp += QString::fromLatin1("Windows CE 5.x");
- break;
- case QSysInfo::WV_CE_6:
- firstPartTemp += QString::fromLatin1("Windows CE 6.x");
- break;
- }
-
+ firstPartTemp += windowsVersionForUAString();
#elif defined Q_OS_DARWIN
#ifdef __i386__ || __x86_64__
firstPartTemp += QString::fromLatin1("Intel Mac OS X");
@@ -3833,6 +3801,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
#elif defined Q_OS_IRIX
firstPartTemp += QString::fromLatin1("SGI Irix");
#elif defined Q_OS_LINUX
+#if !defined(Q_WS_MAEMO_5) && !defined(Q_WS_MAEMO_6)
#if defined(__x86_64__)
firstPartTemp += QString::fromLatin1("Linux x86_64");
@@ -3841,6 +3810,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
#else
firstPartTemp += QString::fromLatin1("Linux");
#endif
+#endif
#elif defined Q_OS_LYNX
firstPartTemp += QString::fromLatin1("LynxOS");
@@ -3890,8 +3860,17 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
firstPartTemp += QString::fromLatin1("Unknown");
#endif
- // language is the split
- firstPartTemp += QString::fromLatin1("; ");
+#if ENABLE(QT_USERAGENT_DEVICEMODEL)
+ // adding Model Number
+ QtMobility::QSystemDeviceInfo systemDeviceInfo;
+
+ QString model = systemDeviceInfo.model();
+ if (!model.isEmpty()) {
+ if (!firstPartTemp.endsWith("; "))
+ firstPartTemp += QString::fromLatin1("; ");
+ firstPartTemp += systemDeviceInfo.model();
+ }
+#endif
firstPartTemp.squeeze();
firstPart = firstPartTemp;
@@ -3911,7 +3890,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
QString thirdPartTemp;
thirdPartTemp.reserve(150);
-#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
thirdPartTemp += QLatin1String(" Mobile Safari/");
#else
thirdPartTemp += QLatin1String(" Safari/");
@@ -3924,14 +3903,6 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
Q_ASSERT(!thirdPart.isNull());
}
- // Language
- QString languageName;
- if (d->client && d->client->ownerWidget())
- languageName = d->client->ownerWidget()->locale().name();
- else
- languageName = QLocale().name();
- languageName.replace(QLatin1Char('_'), QLatin1Char('-'));
-
// Application name/version
QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty()) {
@@ -3943,7 +3914,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const
appName = QString::fromLatin1("Qt/") + QString::fromLatin1(qVersion());
}
- return firstPart + languageName + secondPart + appName + thirdPart;
+ return firstPart + secondPart + appName + thirdPart;
}
@@ -4072,7 +4043,8 @@ quint64 QWebPage::bytesReceived() const
/*!
\fn void QWebPage::repaintRequested(const QRect& dirtyRect)
- This signal is emitted whenever this QWebPage should be updated and no view was set.
+ This signal is emitted whenever this QWebPage should be updated. It's useful
+ when rendering a QWebPage without a QWebView or QGraphicsWebView.
\a dirtyRect contains the area that needs to be updated. To paint the QWebPage get
the mainFrame() and call the render(QPainter*, const QRegion&) method with the
\a dirtyRect as the second parameter.
@@ -4117,6 +4089,8 @@ quint64 QWebPage::bytesReceived() const
At signal emission time the meta-data of the QNetworkReply \a reply is available.
+ \note The receiving slot is responsible for deleting the QNetworkReply \a reply.
+
\note This signal is only emitted if the forwardUnsupportedContent property is set to true.
\sa downloadRequested()