summaryrefslogtreecommitdiffstats
path: root/WebKit/qt/WebCoreSupport
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/qt/WebCoreSupport')
-rw-r--r--WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp60
-rw-r--r--WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h10
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp78
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h3
-rw-r--r--WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp59
-rw-r--r--WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h4
6 files changed, 187 insertions, 27 deletions
diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
index 0ae55d7..09dec71 100644
--- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
+++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
@@ -49,6 +49,7 @@
#include "PrintContext.h"
#include "RenderListItem.h"
#include "RenderTreeAsText.h"
+#include "ScriptController.h"
#include "SecurityOrigin.h"
#include "Settings.h"
#if ENABLE(SVG)
@@ -65,11 +66,13 @@
#include "qwebhistory_p.h"
#include "qwebpage.h"
#include "qwebpage_p.h"
+#include "qwebscriptworld.h"
using namespace WebCore;
CheckPermissionFunctionType* checkPermissionFunction = 0;
RequestPermissionFunctionType* requestPermissionFunction = 0;
+QMap<int, QWebScriptWorld*> m_worldMap;
DumpRenderTreeSupportQt::DumpRenderTreeSupportQt()
{
@@ -392,6 +395,20 @@ QString DumpRenderTreeSupportQt::markerTextForListItem(const QWebElement& listIt
return WebCore::markerTextForListItem(listItem.m_element);
}
+static QString convertToPropertyName(const QString& name)
+{
+ QStringList parts = name.split('-');
+ QString camelCaseName;
+ for (int j = 0; j < parts.count(); ++j) {
+ QString part = parts.at(j);
+ if (j)
+ camelCaseName.append(part.replace(0, 1, part.left(1).toUpper()));
+ else
+ camelCaseName.append(part);
+ }
+ return camelCaseName;
+}
+
QVariantMap DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(const QWebElement& element)
{
QVariantMap res;
@@ -404,7 +421,7 @@ QVariantMap DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(const QWe
for (int i = 0; i < style->length(); i++) {
QString name = style->item(i);
QString value = (static_cast<WebCore::CSSStyleDeclaration*>(style.get()))->getPropertyValue(name);
- res[name] = QVariant(value);
+ res[convertToPropertyName(name)] = QVariant(value);
}
return res;
}
@@ -510,6 +527,11 @@ void DumpRenderTreeSupportQt::dumpResourceLoadCallbacksPath(const QString& path)
FrameLoaderClientQt::dumpResourceLoadCallbacksPath = path;
}
+void DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(bool b)
+{
+ FrameLoaderClientQt::dumpResourceResponseMIMETypes = b;
+}
+
void DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(bool b)
{
FrameLoaderClientQt::sendRequestReturnsNullOnRedirect = b;
@@ -525,6 +547,12 @@ void DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(const QStringList&
FrameLoaderClientQt::sendRequestClearHeaders = headers;
}
+void DumpRenderTreeSupportQt::setCustomPolicyDelegate(bool enabled, bool permissive)
+{
+ FrameLoaderClientQt::policyDelegateEnabled = enabled;
+ FrameLoaderClientQt::policyDelegatePermissive = permissive;
+}
+
void DumpRenderTreeSupportQt::dumpEditingCallbacks(bool b)
{
EditorClientQt::dumpEditingCallbacks = b;
@@ -596,17 +624,17 @@ QString DumpRenderTreeSupportQt::historyItemTarget(const QWebHistoryItem& histor
return (QWebHistoryItemPrivate::core(&it)->target());
}
-QList<QWebHistoryItem> DumpRenderTreeSupportQt::getChildHistoryItems(const QWebHistoryItem& historyItem)
+QMap<QString, QWebHistoryItem> DumpRenderTreeSupportQt::getChildHistoryItems(const QWebHistoryItem& historyItem)
{
QWebHistoryItem it = historyItem;
HistoryItem* item = QWebHistoryItemPrivate::core(&it);
const WebCore::HistoryItemVector& children = item->children();
unsigned size = children.size();
- QList<QWebHistoryItem> kids;
+ QMap<QString, QWebHistoryItem> kids;
for (unsigned i = 0; i < size; ++i) {
QWebHistoryItem kid(new QWebHistoryItemPrivate(children[i].get()));
- kids.prepend(kid);
+ kids.insert(DumpRenderTreeSupportQt::historyItemTarget(kid), kid);
}
return kids;
}
@@ -617,6 +645,30 @@ bool DumpRenderTreeSupportQt::shouldClose(QWebFrame* frame)
return coreFrame->loader()->shouldClose();
}
+void DumpRenderTreeSupportQt::clearScriptWorlds()
+{
+ m_worldMap.clear();
+}
+
+void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldID, const QString& script)
+{
+ QWebScriptWorld* scriptWorld;
+ if (!worldID) {
+ scriptWorld = new QWebScriptWorld();
+ } else if (!m_worldMap.contains(worldID)) {
+ scriptWorld = new QWebScriptWorld();
+ m_worldMap.insert(worldID, scriptWorld);
+ } else
+ scriptWorld = m_worldMap.value(worldID);
+
+ WebCore::Frame* coreFrame = QWebFramePrivate::core(frame);
+
+ ScriptController* proxy = coreFrame->script();
+
+ if (proxy)
+ proxy->executeScriptInWorld(scriptWorld->world(), script, true);
+}
+
// Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release
void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame)
diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h
index 0b94a03..304e65b 100644
--- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h
+++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h
@@ -30,6 +30,7 @@ class QWebElement;
class QWebFrame;
class QWebPage;
class QWebHistoryItem;
+class QWebScriptWorld;
enum NotificationPermission {
NotificationAllowed,
@@ -42,6 +43,7 @@ typedef void (RequestPermissionFunctionType) (QObject* receiver, const QString&)
extern CheckPermissionFunctionType* checkPermissionFunction;
extern RequestPermissionFunctionType* requestPermissionFunction;
+extern QMap<int, QWebScriptWorld*> m_worldMap;
class QWEBKIT_EXPORT DumpRenderTreeSupportQt {
@@ -74,6 +76,8 @@ public:
static void garbageCollectorCollectOnAlternateThread(bool waitUntilDone);
static void setJavaScriptProfilingEnabled(QWebFrame*, bool enabled);
static int javaScriptObjectsCount();
+ static void clearScriptWorlds();
+ static void evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldID, const QString& script);
static void setTimelineProfilingEnabled(QWebPage*, bool enabled);
static void webInspectorExecuteScript(QWebPage* page, long callId, const QString& script);
@@ -106,6 +110,7 @@ public:
static void dumpFrameLoader(bool b);
static void dumpResourceLoadCallbacks(bool b);
+ static void dumpResourceResponseMIMETypes(bool b);
static void dumpResourceLoadCallbacksPath(const QString& path);
static void setWillSendRequestReturnsNullOnRedirect(bool b);
static void setWillSendRequestReturnsNull(bool b);
@@ -115,6 +120,7 @@ public:
static void dumpSetAcceptsEditing(bool b);
static void dumpNotification(bool b);
+
// These functions should eventually turn into public API
// and the "receiver" concept would go away
static void setNotificationsReceiver(QObject* receiver);
@@ -122,11 +128,13 @@ public:
static void setCheckPermissionFunction(CheckPermissionFunctionType*);
static void setRequestPermissionFunction(RequestPermissionFunctionType*);
- static QList<QWebHistoryItem> getChildHistoryItems(const QWebHistoryItem& historyItem);
+ static QMap<QString, QWebHistoryItem> getChildHistoryItems(const QWebHistoryItem& historyItem);
static bool isTargetItem(const QWebHistoryItem& historyItem);
static QString historyItemTarget(const QWebHistoryItem& historyItem);
static bool shouldClose(QWebFrame* frame);
+
+ static void setCustomPolicyDelegate(bool enabled, bool permissive);
};
#endif
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 42b0c49..db731d8 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -38,7 +38,9 @@
#include "FrameTree.h"
#include "FrameView.h"
#include "DocumentLoader.h"
+#include "HitTestResult.h"
#include "MIMETypeRegistry.h"
+#include "MouseEvent.h"
#include "ResourceResponse.h"
#include "Page.h"
#include "PluginData.h"
@@ -127,6 +129,25 @@ static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceRespon
return QString::fromLatin1("<NSURLResponse %1, http status code %2>").arg(url).arg(httpStatusCode);
}
+static QString drtDescriptionSuitableForTestResult(const RefPtr<WebCore::Node> node, int exception)
+{
+ QString result;
+ if (exception) {
+ result.append("ERROR");
+ return result;
+ }
+ if (!node) {
+ result.append("NULL");
+ return result;
+ }
+ result.append(node->nodeName());
+ RefPtr<WebCore::Node> parent = node->parentNode();
+ if (parent) {
+ result.append(" > ");
+ result.append(drtDescriptionSuitableForTestResult(parent, 0));
+ }
+ return result;
+}
namespace WebCore
{
@@ -135,8 +156,32 @@ bool FrameLoaderClientQt::dumpFrameLoaderCallbacks = false;
bool FrameLoaderClientQt::dumpResourceLoadCallbacks = false;
bool FrameLoaderClientQt::sendRequestReturnsNullOnRedirect = false;
bool FrameLoaderClientQt::sendRequestReturnsNull = false;
+bool FrameLoaderClientQt::dumpResourceResponseMIMETypes = false;
+
QStringList FrameLoaderClientQt::sendRequestClearHeaders;
QString FrameLoaderClientQt::dumpResourceLoadCallbacksPath;
+bool FrameLoaderClientQt::policyDelegateEnabled = false;
+bool FrameLoaderClientQt::policyDelegatePermissive = false;
+
+// Taken from DumpRenderTree/chromium/WebViewHost.cpp
+static const char* navigationTypeToString(NavigationType type)
+{
+ switch (type) {
+ case NavigationTypeLinkClicked:
+ return "link clicked";
+ case NavigationTypeFormSubmitted:
+ return "form submitted";
+ case NavigationTypeBackForward:
+ return "back/forward";
+ case NavigationTypeReload:
+ return "reload";
+ case NavigationTypeFormResubmitted:
+ return "form resubmitted";
+ case NavigationTypeOther:
+ return "other";
+ }
+ return "illegal value";
+}
FrameLoaderClientQt::FrameLoaderClientQt()
: m_frame(0)
@@ -910,7 +955,12 @@ void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, u
printf("%s - didReceiveResponse %s\n",
qPrintable(dumpAssignedUrls[identifier]),
qPrintable(drtDescriptionSuitableForTestResult(response)));
- //qDebug() << " got response from" << response.url().string();
+
+ if (dumpResourceResponseMIMETypes) {
+ printf("%s has MIME type %s\n",
+ qPrintable(QFileInfo(drtDescriptionSuitableForTestResult(response.url())).fileName()),
+ qPrintable(QString(response.mimeType())));
+ }
}
void FrameLoaderClientQt::dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long, int)
@@ -1046,6 +1096,32 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFun
Q_ASSERT(m_webFrame);
QNetworkRequest r(request.toNetworkRequest(m_webFrame));
QWebPage*page = m_webFrame->page();
+ PolicyAction result;
+
+ // Currently, this is only enabled by DRT
+ if (policyDelegateEnabled) {
+ RefPtr<Node> node;
+ for (const Event* event = action.event(); event; event = event->underlyingEvent()) {
+ if (event->isMouseEvent()) {
+ const MouseEvent* mouseEvent = static_cast<const MouseEvent*>(event);
+ node = QWebFramePrivate::core(m_webFrame)->eventHandler()->hitTestResultAtPoint(
+ mouseEvent->absoluteLocation(), false).innerNonSharedNode();
+ break;
+ }
+ }
+
+ printf("Policy delegate: attempt to load %s with navigation type '%s'%s\n",
+ qPrintable(drtDescriptionSuitableForTestResult(request.url())), navigationTypeToString(action.type()),
+ (node) ? qPrintable(" originating from " + drtDescriptionSuitableForTestResult(node, 0)) : "");
+
+ if (policyDelegatePermissive)
+ result = PolicyUse;
+ else
+ result = PolicyIgnore;
+
+ callPolicyFunction(function, result);
+ return;
+ }
if (!page->d->acceptNavigationRequest(m_webFrame, r, QWebPage::NavigationType(action.type()))) {
if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted)
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index d858589..b4a3c7e 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -214,10 +214,13 @@ public:
static bool dumpFrameLoaderCallbacks;
static bool dumpResourceLoadCallbacks;
+ static bool dumpResourceResponseMIMETypes;
static QString dumpResourceLoadCallbacksPath;
static bool sendRequestReturnsNullOnRedirect;
static bool sendRequestReturnsNull;
static QStringList sendRequestClearHeaders;
+ static bool policyDelegateEnabled;
+ static bool policyDelegatePermissive;
private:
Frame *m_frame;
diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp
index 26420e5..59ac87b 100644
--- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp
+++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp
@@ -47,6 +47,10 @@ namespace WebCore {
QtFallbackWebPopupCombo::QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup)
: m_ownerPopup(ownerPopup)
{
+ // Install an event filter on the view inside the combo box popup to make sure we know
+ // when the popup got closed. E.g. QComboBox::hidePopup() won't be called when the popup
+ // is closed by a mouse wheel event outside its window.
+ view()->installEventFilter(this);
}
void QtFallbackWebPopupCombo::showPopup()
@@ -71,14 +75,24 @@ void QtFallbackWebPopupCombo::hidePopup()
QComboBox::hidePopup();
- if (QGraphicsProxyWidget* proxy = graphicsProxyWidget())
- proxy->setVisible(false);
-
if (!m_ownerPopup.m_popupVisible)
return;
m_ownerPopup.m_popupVisible = false;
m_ownerPopup.popupDidHide();
+ m_ownerPopup.destroyPopup();
+}
+
+bool QtFallbackWebPopupCombo::eventFilter(QObject* watched, QEvent* event)
+{
+ Q_ASSERT(watched == view());
+
+ if (event->type() == QEvent::Show && !m_ownerPopup.m_popupVisible)
+ showPopup();
+ else if (event->type() == QEvent::Hide && m_ownerPopup.m_popupVisible)
+ hidePopup();
+
+ return false;
}
// QtFallbackWebPopup
@@ -86,19 +100,13 @@ void QtFallbackWebPopupCombo::hidePopup()
QtFallbackWebPopup::QtFallbackWebPopup()
: QtAbstractWebPopup()
, m_popupVisible(false)
- , m_combo(new QtFallbackWebPopupCombo(*this))
- , m_proxy(0)
+ , m_combo(0)
{
- connect(m_combo, SIGNAL(activated(int)),
- SLOT(activeChanged(int)), Qt::QueuedConnection);
}
QtFallbackWebPopup::~QtFallbackWebPopup()
{
- // If we create a proxy, then the deletion of the proxy and the
- // combo will be done by the proxy's parent (QGraphicsWebView)
- if (!m_proxy)
- delete m_combo;
+ destroyPopup();
}
void QtFallbackWebPopup::show()
@@ -109,17 +117,20 @@ void QtFallbackWebPopup::show()
#if ENABLE(SYMBIAN_DIALOG_PROVIDERS)
TRAP_IGNORE(showS60BrowserDialog());
#else
+
+ destroyPopup();
+ m_combo = new QtFallbackWebPopupCombo(*this);
+ connect(m_combo, SIGNAL(activated(int)),
+ SLOT(activeChanged(int)), Qt::QueuedConnection);
+
populate();
m_combo->setCurrentIndex(currentIndex());
QRect rect = geometry();
if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) {
- if (!m_proxy) {
- m_proxy = new QGraphicsProxyWidget(webView);
- m_proxy->setWidget(m_combo);
- } else
- m_proxy->setVisible(true);
- m_proxy->setGeometry(rect);
+ QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(webView);
+ proxy->setWidget(m_combo);
+ proxy->setGeometry(rect);
} else {
m_combo->setParent(pageClient()->ownerWidget());
m_combo->setGeometry(QRect(rect.left(), rect.top(),
@@ -188,13 +199,21 @@ void QtFallbackWebPopup::showS60BrowserDialog()
void QtFallbackWebPopup::hide()
{
- m_combo->hidePopup();
+ // Destroying the QComboBox here cause problems if the popup is in the
+ // middle of its show animation. Instead we rely on the fact that the
+ // Qt::Popup window will hide itself on mouse events outside its window.
}
-void QtFallbackWebPopup::populate()
+void QtFallbackWebPopup::destroyPopup()
{
- m_combo->clear();
+ if (m_combo) {
+ m_combo->deleteLater();
+ m_combo = 0;
+ }
+}
+void QtFallbackWebPopup::populate()
+{
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_combo->model());
Q_ASSERT(model);
diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h
index 6d2e1ff..e6c371f 100644
--- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h
+++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h
@@ -42,6 +42,8 @@ public:
virtual void show();
virtual void hide();
+ void destroyPopup();
+
private slots:
void activeChanged(int);
@@ -49,7 +51,6 @@ private:
friend class QtFallbackWebPopupCombo;
bool m_popupVisible;
QtFallbackWebPopupCombo* m_combo;
- QGraphicsProxyWidget* m_proxy;
void populate();
#if ENABLE(SYMBIAN_DIALOG_PROVIDERS)
@@ -62,6 +63,7 @@ public:
QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup);
virtual void showPopup();
virtual void hidePopup();
+ virtual bool eventFilter(QObject* watched, QEvent* event);
private:
QtFallbackWebPopup& m_ownerPopup;