[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
kenneth at webkit.org
kenneth at webkit.org
Thu Oct 29 20:31:30 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 0292c6aa543a836d3382f4d71b8098e85dff1734
Author: kenneth at webkit.org <kenneth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Sep 21 21:39:38 2009 +0000
WebCore: Implement new QWebPageClient class and let our classes
QWebViewPrivate and QWebGraphicsItemPrivate inherit from it.
Patch by Kenneth Rohde Christiansen <kenneth at webkit.org> on 2009-09-21
Reviewed by Simon Hausmann.
For Qt, platformPageClient() will now return a class derived from
the QWebPageClient, so the patch adapts our Qt hooks to go though
this class and not depend on the QWebView.
* WebCore.pro:
* platform/Widget.h:
* platform/qt/PlatformScreenQt.cpp:
(WebCore::screenDepth):
(WebCore::screenDepthPerComponent):
(WebCore::screenIsMonochrome):
(WebCore::screenRect):
(WebCore::screenAvailableRect):
* platform/qt/PopupMenuQt.cpp:
(WebCore::PopupMenu::show):
* platform/qt/QWebPageClient.h: Added.
* platform/qt/WidgetQt.cpp:
(WebCore::Widget::setCursor):
* plugins/qt/PluginViewQt.cpp:
(WebCore::PluginView::handleKeyboardEvent):
(WebCore::PluginView::getValue):
(WebCore::PluginView::platformStart):
WebKit/qt: For Qt, platformPageClient() will now return a class derived from
the QWebPageClient, so the patch adapts our Qt hooks to go though
this class and not depend on the QWebView.
Patch by Kenneth Rohde Christiansen <kenneth at webkit.org> on 2009-09-21
Reviewed by Simon Hausmann.
* Api/qwebgraphicsitem.cpp:
(QWebGraphicsItemPrivate::scroll):
(QWebGraphicsItemPrivate::update):
(QWebGraphicsItemPrivate::cursor):
(QWebGraphicsItemPrivate::updateCursor):
(QWebGraphicsItemPrivate::screenNumber):
(QWebGraphicsItemPrivate::winId):
(QWebGraphicsItem::event):
(QWebGraphicsItem::setPage):
* Api/qwebgraphicsitem.h:
* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate):
* Api/qwebpage_p.h:
* Api/qwebview.cpp:
(QWebViewPrivate::scroll):
(QWebViewPrivate::update):
(QWebViewPrivate::cursor):
(QWebViewPrivate::updateCursor):
(QWebViewPrivate::screenNumber):
(QWebViewPrivate::winId):
(QWebView::setPage):
(QWebView::event):
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::repaint):
(WebCore::ChromeClientQt::scroll):
(WebCore::ChromeClientQt::platformPageClient):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48604 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f894771..86f6f47 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2009-09-21 Kenneth Rohde Christiansen <kenneth at webkit.org>
+
+ Reviewed by Simon Hausmann.
+
+ Implement new QWebPageClient class and let our classes
+ QWebViewPrivate and QWebGraphicsItemPrivate inherit from it.
+
+ For Qt, platformPageClient() will now return a class derived from
+ the QWebPageClient, so the patch adapts our Qt hooks to go though
+ this class and not depend on the QWebView.
+
+ * WebCore.pro:
+ * platform/Widget.h:
+ * platform/qt/PlatformScreenQt.cpp:
+ (WebCore::screenDepth):
+ (WebCore::screenDepthPerComponent):
+ (WebCore::screenIsMonochrome):
+ (WebCore::screenRect):
+ (WebCore::screenAvailableRect):
+ * platform/qt/PopupMenuQt.cpp:
+ (WebCore::PopupMenu::show):
+ * platform/qt/QWebPageClient.h: Added.
+ * platform/qt/WidgetQt.cpp:
+ (WebCore::Widget::setCursor):
+ * plugins/qt/PluginViewQt.cpp:
+ (WebCore::PluginView::handleKeyboardEvent):
+ (WebCore::PluginView::getValue):
+ (WebCore::PluginView::platformStart):
+
2009-09-21 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Timothy Hatcher.
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 0b19860..f15fd1b 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1901,6 +1901,7 @@ HEADERS += \
platform/network/ResourceRequestBase.h \
platform/network/ResourceResponseBase.h \
platform/qt/ClipboardQt.h \
+ platform/qt/QWebPageClient.h \
platform/qt/QWebPopup.h \
platform/qt/RenderThemeQt.h \
platform/qt/ScrollbarThemeQt.h \
diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h
index 79d8f31..e2a7349 100644
--- a/WebCore/platform/Widget.h
+++ b/WebCore/platform/Widget.h
@@ -74,7 +74,12 @@ typedef BView* PlatformWidget;
#include "PlatformWidget.h"
#endif
+#if PLATFORM(QT)
+class QWebPageClient;
+typedef QWebPageClient* PlatformPageClient;
+#else
typedef PlatformWidget PlatformPageClient;
+#endif
#include "IntPoint.h"
#include "IntRect.h"
diff --git a/WebCore/platform/qt/PlatformScreenQt.cpp b/WebCore/platform/qt/PlatformScreenQt.cpp
index b9bef9d..7ba8350 100644
--- a/WebCore/platform/qt/PlatformScreenQt.cpp
+++ b/WebCore/platform/qt/PlatformScreenQt.cpp
@@ -36,42 +36,54 @@
#include "FrameView.h"
#include "HostWindow.h"
#include "Widget.h"
+#include "QWebPageClient.h"
#include <QApplication>
#include <QDesktopWidget>
namespace WebCore {
+static int screenNumber(Widget* w)
+{
+ if (!w)
+ return 0;
+
+ QWebPageClient* client = w->root()->hostWindow()->platformPageClient();
+ return client ? client->screenNumber() : 0;
+}
+
int screenDepth(Widget* w)
{
- QDesktopWidget* d = QApplication::desktop();
- QWidget *view = w ? w->root()->hostWindow()->platformPageClient() : 0;
- int screenNumber = view ? d->screenNumber(view) : 0;
- return d->screen(screenNumber)->depth();
+ return QApplication::desktop()->screen(screenNumber(w))->depth();
}
int screenDepthPerComponent(Widget* w)
{
- QWidget *view = w ? w->root()->hostWindow()->platformPageClient() : 0;
- return view ? view->depth() : QApplication::desktop()->screen(0)->depth();
+ if (w) {
+ QWebPageClient* client = w->root()->hostWindow()->platformPageClient();
+
+ if (client) {
+ QWidget* view = QWidget::find(client->winId());
+ if (view)
+ return view->depth();
+ }
+ }
+ return QApplication::desktop()->screen(0)->depth();
}
bool screenIsMonochrome(Widget* w)
{
- QDesktopWidget* d = QApplication::desktop();
- QWidget *view = w ? w->root()->hostWindow()->platformPageClient(): 0;
- int screenNumber = view ? d->screenNumber(view) : 0;
- return d->screen(screenNumber)->numColors() < 2;
+ return QApplication::desktop()->screen(screenNumber(w))->numColors() < 2;
}
FloatRect screenRect(Widget* w)
{
- QRect r = QApplication::desktop()->screenGeometry(w ? w->root()->hostWindow()->platformPageClient(): 0);
+ QRect r = QApplication::desktop()->screenGeometry(screenNumber(w));
return FloatRect(r.x(), r.y(), r.width(), r.height());
}
FloatRect screenAvailableRect(Widget* w)
{
- QRect r = QApplication::desktop()->availableGeometry(w ? w->root()->hostWindow()->platformPageClient(): 0);
+ QRect r = QApplication::desktop()->availableGeometry(screenNumber(w));
return FloatRect(r.x(), r.y(), r.width(), r.height());
}
diff --git a/WebCore/platform/qt/PopupMenuQt.cpp b/WebCore/platform/qt/PopupMenuQt.cpp
index 011884a..9ce5838 100644
--- a/WebCore/platform/qt/PopupMenuQt.cpp
+++ b/WebCore/platform/qt/PopupMenuQt.cpp
@@ -30,6 +30,7 @@
#include "FrameView.h"
#include "HostWindow.h"
#include "PopupMenuClient.h"
+#include "QWebPageClient.h"
#include "QWebPopup.h"
#include <QAction>
@@ -85,13 +86,13 @@ void PopupMenu::populate(const IntRect& r)
void PopupMenu::show(const IntRect& r, FrameView* v, int index)
{
- QWidget* window = v->hostWindow()->platformPageClient();
+ QWebPageClient* client = v->hostWindow()->platformPageClient();
populate(r);
QRect rect = r;
rect.moveTopLeft(v->contentsToWindow(r.topLeft()));
rect.setHeight(m_popup->sizeHint().height());
- m_popup->setParent(window);
+ m_popup->setParent(QWidget::find(client->winId()));
m_popup->setGeometry(rect);
m_popup->setCurrentIndex(index);
m_popup->exec();
diff --git a/WebCore/platform/qt/QWebPageClient.h b/WebCore/platform/qt/QWebPageClient.h
new file mode 100644
index 0000000..1fc29a0
--- /dev/null
+++ b/WebCore/platform/qt/QWebPageClient.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef QWebPageClient_h
+#define QWebPageClient_h
+
+#include <QRect>
+
+class QWebPageClient {
+public:
+ virtual void scroll(int dx, int dy, const QRect&) = 0;
+ virtual void update(const QRect&) = 0;
+
+ inline void resetCursor()
+ {
+ if (!cursor().bitmap() && cursor().shape() == m_lastCursor.shape())
+ return;
+ updateCursor(m_lastCursor);
+ }
+
+ inline void setCursor(const QCursor& cursor)
+ {
+ m_lastCursor = cursor;
+ if (!cursor.bitmap() && cursor.shape() == this->cursor().shape())
+ return;
+ updateCursor(cursor);
+ }
+
+ virtual int screenNumber() const = 0;
+ virtual WId winId() const = 0;
+
+protected:
+ virtual QCursor cursor() const = 0;
+ virtual void updateCursor(const QCursor& cursor) = 0;
+
+private:
+ QCursor m_lastCursor;
+};
+
+#endif
diff --git a/WebCore/platform/qt/WidgetQt.cpp b/WebCore/platform/qt/WidgetQt.cpp
index 524b52b..4e82080 100644
--- a/WebCore/platform/qt/WidgetQt.cpp
+++ b/WebCore/platform/qt/WidgetQt.cpp
@@ -30,6 +30,7 @@
*/
#include "config.h"
+#include "Widget.h"
#include "Cursor.h"
#include "Font.h"
@@ -37,8 +38,8 @@
#include "HostWindow.h"
#include "IntRect.h"
#include "ScrollView.h"
-#include "Widget.h"
#include "NotImplemented.h"
+#include "QWebPageClient.h"
#include "qwebframe.h"
#include "qwebframe_p.h"
@@ -81,15 +82,10 @@ void Widget::setFocus()
void Widget::setCursor(const Cursor& cursor)
{
#ifndef QT_NO_CURSOR
- QWidget* widget = root()->hostWindow()->platformPageClient();
-
- if (!widget)
- return;
-
- if (!cursor.impl().bitmap() && widget->cursor().shape() == cursor.impl().shape())
- return;
+ QWebPageClient* pageClient = root()->hostWindow()->platformPageClient();
- widget->setProperty("WebCoreCursor", cursor.impl());
+ if (pageClient)
+ pageClient->setCursor(cursor.impl());
#endif
}
diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp
index e8339e7..908e707 100644
--- a/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/WebCore/plugins/qt/PluginViewQt.cpp
@@ -56,6 +56,7 @@
#include "npruntime_impl.h"
#include "runtime.h"
#include "runtime_root.h"
+#include "QWebPageClient.h"
#include <QKeyEvent>
#include <QWidget>
#include <QX11Info>
@@ -212,7 +213,9 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
XEvent npEvent; // On UNIX NPEvent is a typedef for XEvent.
npEvent.type = (event->type() == "keydown") ? 2 : 3; // ints as Qt unsets KeyPress and KeyRelease
- setSharedXEventFields(npEvent, m_parentFrame->view()->hostWindow()->platformPageClient());
+ QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
+ QWidget* window = QWidget::find(client->winId());
+ setSharedXEventFields(npEvent, window);
setXKeyEventSpecificFields(npEvent, event);
if (!dispatchNPEvent(npEvent))
@@ -350,8 +353,11 @@ NPError PluginView::getValue(NPNVariable variable, void* value)
case NPNVxDisplay:
if (platformPluginWidget())
*(void **)value = platformPluginWidget()->x11Info().display();
- else
- *(void **)value = m_parentFrame->view()->hostWindow()->platformPageClient()->x11Info().display();
+ else {
+ QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
+ QWidget* window = QWidget::find(client->winId());
+ *(void **)value = window->x11Info().display();
+ }
return NPERR_NO_ERROR;
case NPNVxtAppContext:
@@ -451,7 +457,8 @@ bool PluginView::platformStart()
}
if (m_needsXEmbed) {
- setPlatformWidget(new PluginContainerQt(this, m_parentFrame->view()->hostWindow()->platformPageClient()));
+ QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
+ setPlatformWidget(new PluginContainerQt(this, QWidget::find(client->winId())));
} else {
notImplemented();
return false;
diff --git a/WebKit/qt/Api/qwebgraphicsitem.cpp b/WebKit/qt/Api/qwebgraphicsitem.cpp
index 1e491c9..79841ed 100644
--- a/WebKit/qt/Api/qwebgraphicsitem.cpp
+++ b/WebKit/qt/Api/qwebgraphicsitem.cpp
@@ -23,13 +23,15 @@
#include "qwebframe.h"
#include "qwebpage.h"
#include "qwebpage_p.h"
+#include "QWebPageClient.h"
#include <QtGui/QGraphicsScene>
#include <QtGui/QGraphicsView>
#include <QtGui/qapplication.h>
#include <QtGui/qgraphicssceneevent.h>
#include <QtGui/qstyleoption.h>
+#include <QX11Info>
-class QWebGraphicsItemPrivate {
+class QWebGraphicsItemPrivate : public QWebPageClient {
public:
QWebGraphicsItemPrivate(QWebGraphicsItem* parent)
: q(parent)
@@ -38,10 +40,17 @@ public:
, progress(1.0)
{}
- void _q_doScroll(int dx, int dy, const QRect&);
+ virtual void scroll(int dx, int dy, const QRect&);
+ virtual void update(const QRect& dirtyRect);
+
+ virtual QCursor cursor() const;
+ virtual void updateCursor(const QCursor& cursor);
+
+ virtual int screenNumber() const;
+ virtual WId winId() const;
+
void _q_doLoadProgress(int progress);
void _q_doLoadFinished(bool success);
- void _q_doUpdate(const QRect& dirtyRect);
void _q_setStatusBarMessage(const QString& message);
QWebGraphicsItem* q;
@@ -74,16 +83,46 @@ void QWebGraphicsItemPrivate::_q_doLoadFinished(bool success)
emit q->loadFailed();
}
-void QWebGraphicsItemPrivate::_q_doScroll(int dx, int dy, const QRect& rectToScroll)
+void QWebGraphicsItemPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
{
q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll));
}
-void QWebGraphicsItemPrivate::_q_doUpdate(const QRect & dirtyRect)
+void QWebGraphicsItemPrivate::update(const QRect & dirtyRect)
{
q->update(QRectF(dirtyRect));
}
+QCursor QWebGraphicsItemPrivate::cursor() const
+{
+ return q->cursor();
+}
+
+void QWebGraphicsItemPrivate::updateCursor(const QCursor& cursor)
+{
+ q->setCursor(cursor);
+}
+
+int QWebGraphicsItemPrivate::screenNumber() const
+{
+ const QList<QGraphicsView*> views = q->scene()->views();
+
+ if (!views.isEmpty())
+ return views.at(0)->x11Info().screen();
+
+ return 0;
+}
+
+WId QWebGraphicsItemPrivate::winId() const
+{
+ const QList<QGraphicsView*> views = q->scene()->views();
+
+ if (!views.isEmpty())
+ return views.at(0)->winId();
+
+ return 0;
+}
+
void QWebGraphicsItemPrivate::_q_setStatusBarMessage(const QString& s)
{
statusBarMessage = s;
@@ -175,6 +214,24 @@ bool QWebGraphicsItem::sceneEvent(QEvent* event)
bool QWebGraphicsItem::event(QEvent* event)
{
// Re-implemented in order to allows fixing event-related bugs in patch releases.
+
+ if (d->page) {
+#ifndef QT_NO_CURSOR
+#if QT_VERSION >= 0x040400
+ } else if (event->type() == QEvent::CursorChange) {
+ // An unsetCursor will set the cursor to Qt::ArrowCursor.
+ // Thus this cursor change might be a QWidget::unsetCursor()
+ // If this is not the case and it came from WebCore, the
+ // QWebPageClient already has set its cursor internally
+ // to Qt::ArrowCursor, so updating the cursor is always
+ // right, as it falls back to the last cursor set by
+ // WebCore.
+ // FIXME: Add a QEvent::CursorUnset or similar to Qt.
+ if (cursor().shape() == Qt::ArrowCursor)
+ d->resetCursor();
+#endif
+#endif
+ }
return QGraphicsWidget::event(event);
}
@@ -193,6 +250,7 @@ void QWebGraphicsItem::setPage(QWebPage* page)
return;
if (d->page) {
+ d->page->d->client = 0; // unset the page client
if (d->page->parent() == this)
delete d->page;
else
@@ -202,6 +260,7 @@ void QWebGraphicsItem::setPage(QWebPage* page)
d->page = page;
if (!d->page)
return;
+ d->page->d->client = d; // set the page client
QSize size = geometry().size().toSize();
page->setViewportSize(size);
@@ -220,10 +279,6 @@ void QWebGraphicsItem::setPage(QWebPage* page)
this, SLOT(_q_doLoadProgress(int)));
connect(d->page, SIGNAL(loadFinished(bool)),
this, SLOT(_q_doLoadFinished(bool)));
- connect(d->page, SIGNAL(repaintRequested(QRect)),
- this, SLOT(_q_doUpdate(const QRect&)));
- connect(d->page, SIGNAL(scrollRequested(int, int, const QRect&)),
- this, SLOT(_q_doScroll(int, int, const QRect&)));
connect(d->page, SIGNAL(statusBarMessage(const QString&)),
this, SLOT(_q_setStatusBarMessage(const QString&)));
}
diff --git a/WebKit/qt/Api/qwebgraphicsitem.h b/WebKit/qt/Api/qwebgraphicsitem.h
index 223ac42..2c6817a 100644
--- a/WebKit/qt/Api/qwebgraphicsitem.h
+++ b/WebKit/qt/Api/qwebgraphicsitem.h
@@ -133,10 +133,8 @@ protected:
virtual bool sceneEvent(QEvent*);
private:
- Q_PRIVATE_SLOT(d, void _q_doScroll(int dx, int dy, const QRect&))
Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress))
Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
- Q_PRIVATE_SLOT(d, void _q_doUpdate(const QRect& dirtyRect))
Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message))
QWebGraphicsItemPrivate* const d;
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index a27a3ef..e6f611a 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -256,6 +256,7 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
: q(qq)
+ , client(0)
, view(0)
, inspectorFrontend(0)
, inspector(0)
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
index f765f98..9f4216a 100644
--- a/WebKit/qt/Api/qwebpage_p.h
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -56,6 +56,7 @@ class QBitArray;
QT_END_NAMESPACE
class QWebInspector;
+class QWebPageClient;
class QWebPagePrivate {
public:
@@ -129,10 +130,11 @@ public:
QPointer<QWebFrame> mainFrame;
QWebPage *q;
+ QWebPageClient* client;
#ifndef QT_NO_UNDOSTACK
QUndoStack *undoStack;
#endif
- QWidget *view;
+ QWidget* view;
bool insideOpenCall;
quint64 m_totalBytes;
diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp
index d12de94..7f340e3 100644
--- a/WebKit/qt/Api/qwebview.cpp
+++ b/WebKit/qt/Api/qwebview.cpp
@@ -20,6 +20,8 @@
#include "config.h"
#include "qwebview.h"
+
+#include "QWebPageClient.h"
#include "qwebframe.h"
#include "qwebpage_p.h"
@@ -29,14 +31,26 @@
#include "qprinter.h"
#include "qdir.h"
#include "qfile.h"
+#include <QX11Info>
-class QWebViewPrivate {
+class QWebViewPrivate : public QWebPageClient {
public:
QWebViewPrivate(QWebView *view)
: view(view)
, page(0)
, renderHints(QPainter::TextAntialiasing)
- {}
+ {
+ Q_ASSERT(view);
+ }
+
+ virtual void scroll(int dx, int dy, const QRect&);
+ virtual void update(const QRect& dirtyRect);
+
+ virtual QCursor cursor() const;
+ virtual void updateCursor(const QCursor& cursor);
+
+ virtual int screenNumber() const;
+ virtual WId winId() const;
void _q_pageDestroyed();
@@ -46,6 +60,42 @@ public:
QPainter::RenderHints renderHints;
};
+void QWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
+{
+ view->scroll(qreal(dx), qreal(dy), rectToScroll);
+}
+
+void QWebViewPrivate::update(const QRect & dirtyRect)
+{
+ view->update(dirtyRect);
+}
+
+QCursor QWebViewPrivate::cursor() const
+{
+ return view->cursor();
+}
+
+void QWebViewPrivate::updateCursor(const QCursor& cursor)
+{
+ view->setCursor(cursor);
+}
+
+int QWebViewPrivate::screenNumber() const
+{
+ if (view)
+ return view->x11Info().screen();
+
+ return 0;
+}
+
+WId QWebViewPrivate::winId() const
+{
+ if (view)
+ return view->winId();
+
+ return 0;
+}
+
void QWebViewPrivate::_q_pageDestroyed()
{
page = 0;
@@ -195,6 +245,7 @@ void QWebView::setPage(QWebPage* page)
if (d->page == page)
return;
if (d->page) {
+ d->page->d->client = 0; // unset the page client
if (d->page->parent() == this)
delete d->page;
else
@@ -203,6 +254,7 @@ void QWebView::setPage(QWebPage* page)
d->page = page;
if (d->page) {
d->page->setView(this);
+ d->page->d->client = d; // set the page client
d->page->setPalette(palette());
// #### connect signals
QWebFrame *mainFrame = d->page->mainFrame();
@@ -682,24 +734,16 @@ bool QWebView::event(QEvent *e)
#ifndef QT_NO_CURSOR
#if QT_VERSION >= 0x040400
} else if (e->type() == QEvent::CursorChange) {
- // might be a QWidget::unsetCursor()
- if (cursor().shape() == Qt::ArrowCursor) {
- QVariant prop = property("WebCoreCursor");
- if (prop.isValid()) {
- QCursor webCoreCursor = qvariant_cast<QCursor>(prop);
- if (webCoreCursor.shape() != Qt::ArrowCursor)
- setCursor(webCoreCursor);
- }
- }
- } else if (e->type() == QEvent::DynamicPropertyChange) {
- const QByteArray& propName = static_cast<QDynamicPropertyChangeEvent *>(e)->propertyName();
- if (!qstrcmp(propName, "WebCoreCursor")) {
- QVariant prop = property("WebCoreCursor");
- if (prop.isValid()) {
- QCursor webCoreCursor = qvariant_cast<QCursor>(prop);
- setCursor(webCoreCursor);
- }
- }
+ // An unsetCursor will set the cursor to Qt::ArrowCursor.
+ // Thus this cursor change might be a QWidget::unsetCursor()
+ // If this is not the case and it came from WebCore, the
+ // QWebPageClient already has set its cursor internally
+ // to Qt::ArrowCursor, so updating the cursor is always
+ // right, as it falls back to the last cursor set by
+ // WebCore.
+ // FIXME: Add a QEvent::CursorUnset or similar to Qt.
+ if (cursor().shape() == Qt::ArrowCursor)
+ d->resetCursor();
#endif
#endif
} else if (e->type() == QEvent::Leave)
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 84706b4..d7126f9 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,38 @@
+2009-09-21 Kenneth Rohde Christiansen <kenneth at webkit.org>
+
+ Reviewed by Simon Hausmann.
+
+ For Qt, platformPageClient() will now return a class derived from
+ the QWebPageClient, so the patch adapts our Qt hooks to go though
+ this class and not depend on the QWebView.
+
+ * Api/qwebgraphicsitem.cpp:
+ (QWebGraphicsItemPrivate::scroll):
+ (QWebGraphicsItemPrivate::update):
+ (QWebGraphicsItemPrivate::cursor):
+ (QWebGraphicsItemPrivate::updateCursor):
+ (QWebGraphicsItemPrivate::screenNumber):
+ (QWebGraphicsItemPrivate::winId):
+ (QWebGraphicsItem::event):
+ (QWebGraphicsItem::setPage):
+ * Api/qwebgraphicsitem.h:
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebViewPrivate::scroll):
+ (QWebViewPrivate::update):
+ (QWebViewPrivate::cursor):
+ (QWebViewPrivate::updateCursor):
+ (QWebViewPrivate::screenNumber):
+ (QWebViewPrivate::winId):
+ (QWebView::setPage):
+ (QWebView::event):
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::repaint):
+ (WebCore::ChromeClientQt::scroll):
+ (WebCore::ChromeClientQt::platformPageClient):
+
2009-09-21 Yael Aharon <yael.aharon at nokia.com>
Reviewed by Simon Hausmann.
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index a6ddec4..5c65112 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -39,6 +39,7 @@
#include "WindowFeatures.h"
#include "DatabaseTracker.h"
#include "SecurityOrigin.h"
+#include "QWebPageClient.h"
#include "qwebpage.h"
#include "qwebpage_p.h"
@@ -308,12 +309,11 @@ void ChromeClientQt::repaint(const IntRect& windowRect, bool contentChanged, boo
{
// No double buffer, so only update the QWidget if content changed.
if (contentChanged) {
- // Only do implicit paints for QWebView's
- if (QWebView* view = qobject_cast<QWebView*>(m_webPage->view())) {
+ if (platformPageClient()) {
QRect rect(windowRect);
rect = rect.intersected(QRect(QPoint(0, 0), m_webPage->viewportSize()));
if (!rect.isEmpty())
- view->update(rect);
+ platformPageClient()->update(rect);
}
emit m_webPage->repaintRequested(windowRect);
}
@@ -324,9 +324,8 @@ void ChromeClientQt::repaint(const IntRect& windowRect, bool contentChanged, boo
void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect, const IntRect&)
{
- // Only do implicit paints for QWebView's
- if (QWebView* view = qobject_cast<QWebView*>(m_webPage->view()))
- view->scroll(delta.width(), delta.height(), scrollViewRect);
+ if (platformPageClient())
+ platformPageClient()->scroll(delta.width(), delta.height(), scrollViewRect);
emit m_webPage->scrollRequested(delta.width(), delta.height(), scrollViewRect);
}
@@ -344,7 +343,7 @@ IntPoint ChromeClientQt::screenToWindow(const IntPoint& point) const
PlatformPageClient ChromeClientQt::platformPageClient() const
{
- return m_webPage->view();
+ return m_webPage->d->client;
}
void ChromeClientQt::contentsSizeChanged(Frame* frame, const IntSize& size) const
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list