[Qt] Eliminate first set of QtWidgets dependencies from WebCore
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2012 14:14:27 +0000 (14:14 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2012 14:14:27 +0000 (14:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78611

Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

* bindings/js/ScriptControllerQt.cpp: Remove unused include.
* page/qt/EventHandlerQt.cpp:
(WebCore::EventHandler::tabsToAllFormControls): Replace import
of private Qt(Widgets) variable with the default of Qt 5, where
it is also not configurable.
* platform/ContextMenu.h: Remove unused include.
* platform/ContextMenuItem.h: Ditto.
* platform/Widget.h: Use QObject as type for PlatformWidget
instead of QWidget.
* platform/graphics/Icon.h:
(Icon): Prefer QImage over QIcon for storage.
* platform/graphics/gstreamer/PlatformVideoWindowPrivate.h:
(WebCore): Make it compile with QWindow for Qt 5 and QWidget for Qt 4.
* platform/graphics/gstreamer/PlatformVideoWindowQt.cpp:
(FullScreenVideoWindow::FullScreenVideoWindow):
(FullScreenVideoWindow::keyPressEvent):
(FullScreenVideoWindow::event):
(FullScreenVideoWindow::showFullScreen):
(PlatformVideoWindow::PlatformVideoWindow):
* platform/graphics/qt/IconQt.cpp: Revert the implementation of this class
back to notImplemented(). It was trying to load the actual file as QIcon
instead of trying to find a symbolic icon for the given file. We should
probably use the QMimeType API in Qt 5 once it becomes available.
(WebCore::Icon::createIconForFiles):
(WebCore::Icon::paint):
* platform/graphics/qt/ImageQt.cpp:
(graphics): Remove use of QStyle for retrieving icons. Code moved to
WebCoreSupport instead.
* platform/qt/ContextMenuQt.cpp: Removed unused include.
* platform/qt/PlatformScreenQt.cpp: Add #ifdefs to use QScreen API
with Qt 5.
(WebCore::screenDepth):
(WebCore::screenDepthPerComponent):
(WebCore::screenIsMonochrome):
(WebCore::screenRect):
(WebCore::screenAvailableRect):
* platform/qt/QWebPageClient.h: Add hook for showing/hiding widget.
(WebCore):
(QWebPageClient):
* platform/qt/SoundQt.cpp:
(WebCore::systemBeep): Beep is not implemented in Qt 5 and its use is
questionable. Move back to notImplemented() until proper QPA API becomes
available in Qt 5 (if ever...).
* platform/qt/WidgetQt.cpp: Delegate QWidget specific show/hide calls
to the PageClient, out of WebCore.
(WebCore::Widget::Widget):
(WebCore::Widget::show):
(WebCore::Widget::hide):
* plugins/PluginView.h: Remove unused include.
* rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject): When dumping properties of
QWidget, use the QObject property API to retrieve the values instead of
QWidget specific API. Removed the mask from the dump as it's not available
as property and our layout tests don't seem to use it.

Source/WebKit/qt:

* Api/qwebpage.cpp: Add missing includes.
* WebCoreSupport/DumpRenderTreeSupportQt.cpp: Ditto.
* WebCoreSupport/FrameLoaderClientQt.cpp: Make it compile by casting
the QObject based PlatformWidget back to QWidget before doing QWidget
specific function calls.
* WebCoreSupport/InitWebCoreQt.cpp:
(WebCore::initializeWebCoreQt): Moved QStyle specific web-graphic initialization
here from WebCore.
* WebCoreSupport/PageClientQt.cpp:
(WebCore::PageClientQWidget::setWidgetVisible): Implement show/hiding of widgets
through delegation to QWidget.
(WebCore):
(WebCore::PageClientQGraphicsWidget::setWidgetVisible): Provide empty widget
show/hide implementation, as it doesn't seem to make sense for graphicsviews.
* WebCoreSupport/PageClientQt.h:
(PageClientQWidget):
(PageClientQGraphicsWidget):

Source/WebKit2:

* UIProcess/qt/QtWebPageEventHandler.cpp: Add missing QCursor include
to fix compilation.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107811 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptControllerQt.cpp
Source/WebCore/page/qt/EventHandlerQt.cpp
Source/WebCore/platform/ContextMenu.h
Source/WebCore/platform/ContextMenuItem.h
Source/WebCore/platform/Widget.h
Source/WebCore/platform/graphics/Icon.h
Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowPrivate.h
Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowQt.cpp
Source/WebCore/platform/graphics/qt/IconQt.cpp
Source/WebCore/platform/graphics/qt/ImageQt.cpp
Source/WebCore/platform/qt/ContextMenuQt.cpp
Source/WebCore/platform/qt/PlatformScreenQt.cpp
Source/WebCore/platform/qt/QWebPageClient.h
Source/WebCore/platform/qt/SoundQt.cpp
Source/WebCore/platform/qt/WidgetQt.cpp
Source/WebCore/plugins/PluginView.h
Source/WebCore/plugins/qt/PluginViewQt.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp
Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp
Source/WebKit/qt/WebCoreSupport/PageClientQt.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp

index 419880a..bf84921 100644 (file)
@@ -1,3 +1,65 @@
+2012-02-14  Simon Hausmann  <simon.hausmann@nokia.com>
+
+        [Qt] Eliminate first set of QtWidgets dependencies from WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=78611
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * bindings/js/ScriptControllerQt.cpp: Remove unused include.
+        * page/qt/EventHandlerQt.cpp:
+        (WebCore::EventHandler::tabsToAllFormControls): Replace import
+        of private Qt(Widgets) variable with the default of Qt 5, where
+        it is also not configurable.
+        * platform/ContextMenu.h: Remove unused include.
+        * platform/ContextMenuItem.h: Ditto.
+        * platform/Widget.h: Use QObject as type for PlatformWidget
+        instead of QWidget.
+        * platform/graphics/Icon.h:
+        (Icon): Prefer QImage over QIcon for storage.
+        * platform/graphics/gstreamer/PlatformVideoWindowPrivate.h:
+        (WebCore): Make it compile with QWindow for Qt 5 and QWidget for Qt 4.
+        * platform/graphics/gstreamer/PlatformVideoWindowQt.cpp:
+        (FullScreenVideoWindow::FullScreenVideoWindow):
+        (FullScreenVideoWindow::keyPressEvent):
+        (FullScreenVideoWindow::event):
+        (FullScreenVideoWindow::showFullScreen):
+        (PlatformVideoWindow::PlatformVideoWindow):
+        * platform/graphics/qt/IconQt.cpp: Revert the implementation of this class
+        back to notImplemented(). It was trying to load the actual file as QIcon
+        instead of trying to find a symbolic icon for the given file. We should
+        probably use the QMimeType API in Qt 5 once it becomes available.
+        (WebCore::Icon::createIconForFiles):
+        (WebCore::Icon::paint):
+        * platform/graphics/qt/ImageQt.cpp:
+        (graphics): Remove use of QStyle for retrieving icons. Code moved to
+        WebCoreSupport instead.
+        * platform/qt/ContextMenuQt.cpp: Removed unused include.
+        * platform/qt/PlatformScreenQt.cpp: Add #ifdefs to use QScreen API
+        with Qt 5.
+        (WebCore::screenDepth):
+        (WebCore::screenDepthPerComponent):
+        (WebCore::screenIsMonochrome):
+        (WebCore::screenRect):
+        (WebCore::screenAvailableRect):
+        * platform/qt/QWebPageClient.h: Add hook for showing/hiding widget.
+        (WebCore):
+        (QWebPageClient):
+        * platform/qt/SoundQt.cpp:
+        (WebCore::systemBeep): Beep is not implemented in Qt 5 and its use is
+        questionable. Move back to notImplemented() until proper QPA API becomes
+        available in Qt 5 (if ever...).
+        * platform/qt/WidgetQt.cpp: Delegate QWidget specific show/hide calls
+        to the PageClient, out of WebCore.
+        (WebCore::Widget::Widget):
+        (WebCore::Widget::show):
+        (WebCore::Widget::hide):
+        * plugins/PluginView.h: Remove unused include.
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::RenderTreeAsText::writeRenderObject): When dumping properties of
+        QWidget, use the QObject property API to retrieve the values instead of
+        QWidget specific API. Removed the mask from the dump as it's not available
+        as property and our layout tests don't seem to use it.
+
 2012-02-15  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: Fix minor design issues in the Spectrum color picker
index a8cdf9d..979a4f6 100644 (file)
@@ -42,8 +42,6 @@
 #include "qt_instance.h"
 #include "runtime_root.h"
 
-#include <QWidget>
-
 namespace WebCore {
 
 PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(WebCore::Widget* widget)
index 06db104..8aebb9c 100644 (file)
 #include "RenderWidget.h"
 #include "Scrollbar.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
 QT_BEGIN_NAMESPACE
 Q_GUI_EXPORT extern bool qt_tab_all_widgets; // from qapplication.cpp
 QT_END_NAMESPACE
+#endif
 
 namespace WebCore {
 
@@ -64,7 +66,11 @@ const double EventHandler::TextDragDelay = 0.0;
 
 bool EventHandler::tabsToAllFormControls(KeyboardEvent* event) const
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    return !isKeyboardOptionTab(event);
+#else
     return (isKeyboardOptionTab(event) ? !qt_tab_all_widgets : qt_tab_all_widgets);
+#endif
 }
 
 void EventHandler::focusDocumentView()
index 2c50a92..00ceb20 100644 (file)
@@ -33,8 +33,6 @@
 #include "PlatformString.h"
 #if PLATFORM(MAC)
 #include <wtf/RetainPtr.h>
-#elif PLATFORM(QT)
-#include <QMenu>
 #elif PLATFORM(WIN)
 #include <windows.h>
 #endif
index 2520c64..15bff48 100644 (file)
@@ -39,8 +39,6 @@ typedef struct tagMENUITEMINFOW MENUITEMINFO;
 #elif PLATFORM(GTK)
 typedef struct _GtkMenuItem GtkMenuItem;
 typedef struct _GtkAction GtkAction;
-#elif PLATFORM(QT)
-#include <QAction>
 #elif PLATFORM(WX)
 class wxMenuItem;
 #endif
index 3f19b61..d710716 100644 (file)
@@ -63,9 +63,9 @@ typedef GtkWidget* PlatformWidget;
 
 #if PLATFORM(QT)
 QT_BEGIN_NAMESPACE
-class QWidget;
+class QObject;
 QT_END_NAMESPACE
-typedef QWidget* PlatformWidget;
+typedef QObject* PlatformWidget;
 #endif
 
 #if PLATFORM(WX)
index 781a08c..b703c71 100644 (file)
@@ -32,7 +32,7 @@ OBJC_CLASS NSImage;
 #elif PLATFORM(WIN)
 typedef struct HICON__* HICON;
 #elif PLATFORM(QT)
-#include <QIcon>
+#include <QImage>
 #elif PLATFORM(GTK)
 typedef struct _GdkPixbuf GdkPixbuf;
 #elif PLATFORM(EFL)
@@ -70,7 +70,7 @@ private:
     HICON m_hIcon;
 #elif PLATFORM(QT)
     Icon();
-    QIcon m_icon;
+    QImage m_image;
 #elif PLATFORM(GTK)
     Icon();
     GdkPixbuf* m_icon;
index eeb08c2..33600f6 100644 (file)
 #ifndef PlatformVideoWindowPrivate_h
 #define PlatformVideoWindowPrivate_h
 
+#include <QEvent>
 #include <QTimer>
-#include <QWidget>
 
-QT_BEGIN_NAMESPACE
-class QKeyEvent;
-QT_END_NAMESPACE
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QWindow>
+#else
+#include <QWidget>
+#endif
 
 namespace WebCore {
 
 class HTMLVideoElement;
 
-class FullScreenVideoWindow: public QWidget {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+typedef QWindow Base;
+#else
+typedef QWidget Base;
+#endif
+
+class FullScreenVideoWindow: public Base {
 Q_OBJECT
 public:
     FullScreenVideoWindow();
@@ -39,7 +47,6 @@ public:
 signals:
     void closed();
 protected:
-    void closeEvent(QCloseEvent*);
     void keyPressEvent(QKeyEvent*);
     bool event(QEvent*);
 
index 0a6c45b..06a7925 100644 (file)
 #include "HTMLVideoElement.h"
 #include "PlatformVideoWindowPrivate.h"
 
+#include <QCursor>
 #include <QGuiApplication>
-#include <QDesktopWidget>
 #include <QKeyEvent>
 #include <QPalette>
+
 using namespace WebCore;
 
 #ifndef QT_NO_CURSOR
@@ -34,13 +35,14 @@ static const int gHideMouseCursorDelay = 3000;
 #endif
 
 FullScreenVideoWindow::FullScreenVideoWindow()
-    : QWidget(0, Qt::Window)
-    , m_mediaElement(0)
+    : m_mediaElement(0)
 {
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
     setAttribute(Qt::WA_NativeWindow);
-    setWindowModality(Qt::ApplicationModal);
     setAttribute(Qt::WA_NoSystemBackground, true);
     setAttribute(Qt::WA_PaintOnScreen, true);
+#endif
+    setWindowModality(Qt::ApplicationModal);
 
 #ifndef QT_NO_CURSOR
     m_cursorTimer.setSingleShot(true);
@@ -53,18 +55,6 @@ void FullScreenVideoWindow::setVideoElement(HTMLVideoElement* element)
     m_mediaElement = element;
 }
 
-void FullScreenVideoWindow::closeEvent(QCloseEvent*)
-{
-#ifndef QT_NO_CURSOR
-    m_cursorTimer.stop();
-#endif
-    setMouseTracking(false);
-    releaseMouse();
-#ifndef QT_NO_CURSOR
-    QGuiApplication::restoreOverrideCursor();
-#endif
-}
-
 void FullScreenVideoWindow::keyPressEvent(QKeyEvent* ev)
 {
     if (m_mediaElement && ev->key() == Qt::Key_Space) {
@@ -74,7 +64,7 @@ void FullScreenVideoWindow::keyPressEvent(QKeyEvent* ev)
             m_mediaElement->play();
     } else if (ev->key() == Qt::Key_Escape)
         emit closed();
-    QWidget::keyPressEvent(ev);
+    Base::keyPressEvent(ev);
 }
 
 bool FullScreenVideoWindow::event(QEvent* ev)
@@ -88,17 +78,34 @@ bool FullScreenVideoWindow::event(QEvent* ev)
         emit closed();
         ev->accept();
         return true;
+    case QEvent::Close:
+#ifndef QT_NO_CURSOR
+        m_cursorTimer.stop();
+#endif
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+        setMouseTracking(false);
+        releaseMouse();
+#endif
+#ifndef QT_NO_CURSOR
+        QGuiApplication::restoreOverrideCursor();
+#endif
+        break;
     default:
-        return QWidget::event(ev);
+        break;
     }
+    return Base::event(ev);
 }
 
 void FullScreenVideoWindow::showFullScreen()
 {
-    QWidget::showFullScreen();
+    Base::showFullScreen();
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
     setMouseTracking(true);
+#endif
     raise();
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
     setFocus();
+#endif
     hideCursor();
 }
 
@@ -120,14 +127,18 @@ void FullScreenVideoWindow::showCursor()
 
 PlatformVideoWindow::PlatformVideoWindow()
 {
-    m_window = new FullScreenVideoWindow();
-    m_window->setWindowFlags(m_window->windowFlags() | Qt::FramelessWindowHint);
+    Base* win = new FullScreenVideoWindow();
+    m_window = win;
+    win->setWindowFlags(win->windowFlags() | Qt::FramelessWindowHint);
+    // FIXME: Port to Qt 5.
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
     QPalette p;
     p.setColor(QPalette::Base, Qt::black);
     p.setColor(QPalette::Window, Qt::black);
-    m_window->setPalette(p);
-    m_window->showFullScreen();
-    m_videoWindowId = m_window->winId();
+    win->setPalette(p);
+#endif
+    win->showFullScreen();
+    m_videoWindowId = win->winId();
 }
 
 PlatformVideoWindow::~PlatformVideoWindow()
index eb09eda..7d2613f 100644 (file)
 #include "Icon.h"
 
 #include "GraphicsContext.h"
-#include "PlatformString.h"
 #include "IntRect.h"
+#include "NotImplemented.h"
+#include "PlatformString.h"
 
-#include <qpainter.h>
-#include <qpixmap.h>
-#include <qrect.h>
-#include <qglobal.h>
 
 namespace WebCore {
 
@@ -41,27 +38,16 @@ Icon::~Icon()
 }
 
 // FIXME: Move the code to ChromeClient::iconForFiles().
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
+PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
 {
-    if (filenames.isEmpty())
-        return 0;
-
-    if (filenames.size() == 1) {
-        RefPtr<Icon> i = adoptRef(new Icon);
-        i->m_icon = QIcon(filenames[0]);
-        return i.release();
-    }
-
-    //FIXME: Implement this
+    // FIXME: Should use QMimeType in Qt 5.
+    notImplemented();
     return 0;
 }
 
-void Icon::paint(GraphicsContext* ctx, const IntRect& rect)
+void Icon::paint(GraphicsContext*, const IntRect&)
 {
-    QPixmap px = m_icon.pixmap(rect.size());
-    QPainter *p = static_cast<QPainter*>(ctx->platformContext());
-    if (p && !px.isNull())
-        p->drawPixmap(rect.x(), rect.y(), px);
+    notImplemented();
 }
 
 }
index fa78e01..eb4be2d 100644 (file)
 #include "ShadowBlur.h"
 #include "StillImageQt.h"
 
-#include <QApplication>
+#include <QCoreApplication>
 #include <QDebug>
 #include <QImage>
 #include <QImageReader>
 #include <QPainter>
 #include <QPixmap>
-#include <QStyle>
 #include <QTransform>
 
 #include <math.h>
@@ -81,10 +80,6 @@ static WebGraphicHash* graphics()
         hash->insert("deleteButton", QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
         // QWebSettings::InputSpeechButtonGraphic
         hash->insert("inputSpeech", QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
-        // QWebSettings::SearchCancelButtonGraphic
-        hash->insert("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
-        // QWebSettings::SearchCancelButtonPressedGraphic
-        hash->insert("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
     }
 
     return hash;
index 61aab6d..0fefeb9 100644 (file)
@@ -30,7 +30,6 @@
 #include <Document.h>
 #include <Frame.h>
 #include <FrameView.h>
-#include <QAction>
 #include <wtf/Assertions.h>
 
 namespace WebCore {
index 3c1329b..62dcf50 100644 (file)
 #include "NotImplemented.h"
 #include "Widget.h"
 #include "QWebPageClient.h"
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QGuiApplication>
+#include <QScreen>
+#else
 #include <QApplication>
 #include <QDesktopWidget>
+#endif
 
 namespace WebCore {
 
@@ -66,11 +71,20 @@ static int screenNumber(Widget* w)
 
 int screenDepth(Widget* w)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    return QGuiApplication::screens().value(screenNumber(w))->depth();
+#else
     return QApplication::desktop()->screen(screenNumber(w))->depth();
+#endif
 }
 
 int screenDepthPerComponent(Widget* w)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    int depth = QGuiApplication::primaryScreen()->depth();
+    // FIXME: Use widget's screen
+    Q_UNUSED(w);
+#else
     int depth = QApplication::desktop()->screen(0)->depth();
     if (w) {
         QWebPageClient* client = w->root()->hostWindow()->platformPageClient();
@@ -81,6 +95,7 @@ int screenDepthPerComponent(Widget* w)
                 depth = view->depth();
         }
     }
+#endif
     // An interface to establish the actual number of bits per color
     // doesn't exist in Qt, or probably at all, so use common-sense
     // values for each screen depth and assume RGB/RGBA where appropriate.
@@ -99,18 +114,32 @@ int screenDepthPerComponent(Widget* w)
 
 bool screenIsMonochrome(Widget* w)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    Q_UNUSED(w);
+    // FIXME: In Qt 5 colorCount() isn't even implemented beyond returning 256 :)
+    return false;
+#else
     return QApplication::desktop()->screen(screenNumber(w))->colorCount() == 2;
+#endif
 }
 
 FloatRect screenRect(Widget* widget)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    QRect r = QGuiApplication::screens().value(screenNumber(widget))->geometry();
+#else
     QRect r = QApplication::desktop()->screenGeometry(screenNumber(widget));
+#endif
     return FloatRect(r.x(), r.y(), r.width(), r.height());
 }
 
 FloatRect screenAvailableRect(Widget* widget)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    QRect r = QGuiApplication::screens().value(screenNumber(widget))->availableGeometry();
+#else
     QRect r = QApplication::desktop()->availableGeometry(screenNumber(widget));
+#endif
     return FloatRect(r.x(), r.y(), r.width(), r.height());
 }
 
index 8396cac..c8f24f3 100644 (file)
@@ -41,6 +41,10 @@ QT_BEGIN_NAMESPACE
 class QStyle;
 QT_END_NAMESPACE
 
+namespace WebCore {
+class Widget;
+}
+
 class QWebPageClient {
 public:
     virtual ~QWebPageClient() { }
@@ -95,6 +99,8 @@ public:
 
     virtual QRectF windowRect() const = 0;
 
+    virtual void setWidgetVisible(WebCore::Widget*, bool visible) = 0;
+
 protected:
 #ifndef QT_NO_CURSOR
     virtual QCursor cursor() const = 0;
index bf9e142..7e3c991 100644 (file)
 #include "config.h"
 #include "Sound.h"
 
-#include <QApplication>
+#include <NotImplemented.h>
 
 namespace WebCore {
 
 void systemBeep()
 {
-    QApplication::beep();
+    // FIXME: Not implemented in Qt 5 right now. The implementation in QApplication:beep()
+    // is empty. If anyone is going to bother implementing this via QPlatformNativeInterface, then
+    // we could use that here.
+    notImplemented();
 }
 
 }
index 5215e66..86ee430 100644 (file)
 #include <QDebug>
 #include <QPaintEngine>
 #include <QPainter>
-#include <QWidget>
 
 namespace WebCore {
 
-Widget::Widget(QWidget* widget)
+Widget::Widget(PlatformWidget widget)
 {
     init(widget);
 }
@@ -89,16 +88,24 @@ void Widget::show()
 {
     setSelfVisible(true);
 
-    if (isParentVisible() && platformWidget())
-        platformWidget()->show();
+    if (!isParentVisible() || !platformWidget())
+        return;
+
+    QWebPageClient* client = root()->hostWindow()->platformPageClient();
+    if (client)
+        client->setWidgetVisible(this, true);
 }
 
 void Widget::hide()
 {
     setSelfVisible(false);
 
-    if (isParentVisible() && platformWidget())
-        platformWidget()->hide();
+    if (!isParentVisible() || !platformWidget())
+        return;
+
+    QWebPageClient* client = root()->hostWindow()->platformPageClient();
+    if (client)
+        client->setWidgetVisible(this, false);
 }
 
 void Widget::paint(GraphicsContext*, const IntRect&)
index cb3ee42..1128522 100644 (file)
@@ -61,7 +61,6 @@ typedef PlatformWidget PlatformPluginWidget;
 #include "TextureMapperPlatformLayer.h"
 #endif
 
-#include <QGraphicsItem>
 #include <QImage>
 QT_BEGIN_NAMESPACE
 class QPainter;
index e2c55cf..ff912db 100644 (file)
@@ -189,7 +189,7 @@ void PluginView::setFocus(bool focused)
 {
     if (platformPluginWidget()) {
         if (focused)
-            platformPluginWidget()->setFocus(Qt::OtherFocusReason);
+            static_cast<QWidget*>(platformPluginWidget())->setFocus(Qt::OtherFocusReason);
     } else {
         Widget::setFocus(focused);
     }
@@ -572,7 +572,8 @@ void PluginView::setNPWindowIfNeeded()
     m_hasPendingGeometryChange = false;
 
     if (m_isWindowed) {
-        platformPluginWidget()->setGeometry(m_windowRect);
+        QWidget* widget = static_cast<QWidget*>(platformPluginWidget());
+        widget->setGeometry(m_windowRect);
 
         // Cut out areas of the plugin occluded by iframe shims
         Vector<IntRect> cutOutRects;
@@ -584,8 +585,8 @@ void PluginView::setNPWindowIfNeeded()
         }
         // if setMask is set with an empty QRegion, no clipping will
         // be performed, so in that case we hide the plugin view
-        platformPluginWidget()->setVisible(!clipRegion.isEmpty());
-        platformPluginWidget()->setMask(clipRegion);
+        widget->setVisible(!clipRegion.isEmpty());
+        widget->setMask(clipRegion);
 
         m_npWindow.x = m_windowRect.x();
         m_npWindow.y = m_windowRect.y();
@@ -639,7 +640,7 @@ void PluginView::setParentVisible(bool visible)
     Widget::setParentVisible(visible);
 
     if (isSelfVisible() && platformPluginWidget())
-        platformPluginWidget()->setVisible(visible);
+        static_cast<QWidget*>(platformPluginWidget())->setVisible(visible);
 }
 
 NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32_t len, const char* buf)
@@ -742,8 +743,9 @@ void PluginView::invalidateRect(const IntRect& rect)
         if (platformWidget()) {
             // update() will schedule a repaint of the widget so ensure
             // its knowledge of its position on the page is up to date.
-            platformWidget()->setGeometry(m_windowRect);
-            platformWidget()->update(rect);
+            QWidget* w = static_cast<QWidget*>(platformWidget());
+            w->setGeometry(m_windowRect);
+            w->update(rect);
         }
         return;
     }
@@ -892,7 +894,7 @@ bool PluginView::platformStart()
     wsi->type = 0;
 
     if (m_isWindowed) {
-        const QX11Info* x11Info = &platformPluginWidget()->x11Info();
+        const QX11Info* x11Info = &static_cast<QWidget*>(platformPluginWidget())->x11Info();
 
         wsi->display = x11Info->display();
         wsi->visual = (Visual*)x11Info->visual();
@@ -900,7 +902,7 @@ bool PluginView::platformStart()
         wsi->colormap = x11Info->colormap();
 
         m_npWindow.type = NPWindowTypeWindow;
-        m_npWindow.window = (void*)platformPluginWidget()->winId();
+        m_npWindow.window = (void*)static_cast<QWidget*>(platformPluginWidget())->winId();
         m_npWindow.width = -1;
         m_npWindow.height = -1;
     } else {
index 06e0fe9..4cb4c0e 100644 (file)
@@ -69,7 +69,7 @@
 #endif
 
 #if PLATFORM(QT)
-#include <QWidget>
+#include <QVariant>
 #endif
 
 namespace WebCore {
@@ -475,14 +475,13 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
     if (o.isRenderPart()) {
         const RenderPart* part = toRenderPart(const_cast<RenderObject*>(&o));
         if (part->widget() && part->widget()->platformWidget()) {
-            QWidget* wid = part->widget()->platformWidget();
+            QObject* wid = part->widget()->platformWidget();
 
             ts << " [QT: ";
-            ts << "geometry: {" << wid->geometry() << "} ";
-            ts << "isHidden: " << wid->isHidden() << " ";
+            ts << "geometry: {" << wid->property("geometry").toRect() << "} ";
+            ts << "isHidden: " << !wid->property("isVisible").toBool() << " ";
             ts << "isSelfVisible: " << part->widget()->isSelfVisible() << " ";
-            ts << "isParentVisible: " << part->widget()->isParentVisible() << " ";
-            ts << "mask: {" << wid->mask().boundingRect() << "} ] ";
+            ts << "isParentVisible: " << part->widget()->isParentVisible() << " ] ";
         }
     }
 #endif
index a2d31c9..4234fbb 100644 (file)
 #include "WindowFeatures.h"
 #include "WorkerThread.h"
 
+#include <QAction>
 #include <QApplication>
 #include <QBasicTimer>
 #include <QBitArray>
 #include <QDropEvent>
 #include <QFileDialog>
 #include <QInputDialog>
+#include <QMenu>
 #include <QMessageBox>
 #include <QNetworkProxy>
 #include <QUndoStack>
index f30ae47..39ee1b4 100644 (file)
@@ -1,3 +1,28 @@
+2012-02-14  Simon Hausmann  <simon.hausmann@nokia.com>
+
+        [Qt] Eliminate first set of QtWidgets dependencies from WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=78611
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * Api/qwebpage.cpp: Add missing includes.
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp: Ditto.
+        * WebCoreSupport/FrameLoaderClientQt.cpp: Make it compile by casting
+        the QObject based PlatformWidget back to QWidget before doing QWidget
+        specific function calls.
+        * WebCoreSupport/InitWebCoreQt.cpp:
+        (WebCore::initializeWebCoreQt): Moved QStyle specific web-graphic initialization
+        here from WebCore.
+        * WebCoreSupport/PageClientQt.cpp:
+        (WebCore::PageClientQWidget::setWidgetVisible): Implement show/hiding of widgets
+        through delegation to QWidget.
+        (WebCore):
+        (WebCore::PageClientQGraphicsWidget::setWidgetVisible): Provide empty widget
+        show/hide implementation, as it doesn't seem to make sense for graphicsviews.
+        * WebCoreSupport/PageClientQt.h:
+        (PageClientQWidget):
+        (PageClientQGraphicsWidget):
+
 2012-02-15  Kenneth Rohde Christiansen  <kenneth@webkit.org>
 
         [Qt] Be smarted with tile usages during tiling
index 62aa643..92c98cd 100644 (file)
@@ -98,6 +98,9 @@
 #include "MediaPlayerPrivateQt.h"
 #endif
 
+#include <QAction>
+#include <QMenu>
+
 using namespace WebCore;
 
 QMap<int, QWebScriptWorld*> m_worldMap;
index 20f31b3..ab7e95c 100644 (file)
@@ -1451,15 +1451,16 @@ public:
     virtual void invalidateRect(const IntRect& r)
     { 
         if (platformWidget())
-            platformWidget()->update(r);
+            static_cast<QWidget*>(platformWidget())->update(r);
     }
     virtual void frameRectsChanged()
     {
-        if (!platformWidget())
+        QWidget* widget = static_cast<QWidget*>(platformWidget());
+        if (!widget)
             return;
 
         IntRect windowRect = convertToContainingWindow(IntRect(0, 0, frameRect().width(), frameRect().height()));
-        platformWidget()->setGeometry(windowRect);
+        widget->setGeometry(windowRect);
 
         ScrollView* parentScrollView = parent();
         if (!parentScrollView)
@@ -1468,14 +1469,14 @@ public:
         ASSERT(parentScrollView->isFrameView());
         IntRect clipRect(static_cast<FrameView*>(parentScrollView)->windowClipRect());
         clipRect.move(-windowRect.x(), -windowRect.y());
-        clipRect.intersect(platformWidget()->rect());
+        clipRect.intersect(widget->rect());
 
         QRegion clipRegion = QRegion(clipRect);
-        platformWidget()->setMask(clipRegion);
+        widget->setMask(clipRegion);
 
         handleVisibility();
 
-        platformWidget()->update();
+        widget->update();
     }
 
     virtual void show()
@@ -1490,10 +1491,11 @@ private:
         if (!isVisible())
             return;
 
+        QWidget* widget = static_cast<QWidget*>(platformWidget());
         // If setMask is set with an empty QRegion, no clipping will
         // be performed, so in that case we hide the platformWidget.
-        QRegion mask = platformWidget()->mask();
-        platformWidget()->setVisible(!mask.isEmpty());
+        QRegion mask = widget->mask();
+        widget->setVisible(!mask.isEmpty());
     }
 };
 
index 40f6fe7..5cbd82c 100644 (file)
@@ -30,6 +30,7 @@
 #include "config.h"
 #include "InitWebCoreQt.h"
 
+#include "Image.h"
 #include "NotImplemented.h"
 #include "PlatformStrategiesQt.h"
 #include "ScriptController.h"
@@ -39,6 +40,8 @@
 #endif
 
 #include "qwebelement_p.h"
+#include <QApplication>
+#include <QStyle>
 
 #include <runtime/InitializeThreading.h>
 #include <wtf/MainThread.h>
@@ -63,6 +66,11 @@ void initializeWebCoreQt()
     InitWebCoreSystemInterface();
 #endif
 
+    // QWebSettings::SearchCancelButtonGraphic
+    Image::setPlatformResource("searchCancelButton", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
+    // QWebSettings::SearchCancelButtonPressedGraphic
+    Image::setPlatformResource("searchCancelButtonPressed", QApplication::style()->standardPixmap(QStyle::SP_DialogCloseButton));
+
     initialized = true;
 }
 
index f3a27b4..f454092 100644 (file)
@@ -178,6 +178,14 @@ QRectF PageClientQWidget::windowRect() const
     return QRectF(view->window()->geometry());
 }
 
+void PageClientQWidget::setWidgetVisible(Widget* widget, bool visible)
+{
+    QWidget* qtWidget = qobject_cast<QWidget*>(widget->platformWidget());
+    if (!qtWidget)
+        return;
+    qtWidget->setVisible(visible);
+}
+
 #if !defined(QT_NO_GRAPHICSVIEW)
 PageClientQGraphicsWidget::~PageClientQGraphicsWidget()
 {
@@ -405,6 +413,11 @@ QStyle* PageClientQGraphicsWidget::style() const
     return view->style();
 }
 
+void PageClientQGraphicsWidget::setWidgetVisible(Widget*, bool)
+{
+    // Doesn't make sense, does it?
+}
+
 QRectF PageClientQGraphicsWidget::windowRect() const
 {
     if (!view->scene())
index 0388c20..3888160 100644 (file)
@@ -97,6 +97,8 @@ public:
 
     virtual QRectF windowRect() const;
 
+    virtual void setWidgetVisible(Widget*, bool visible);
+
     QWidget* view;
     QWebPage* page;
 
@@ -198,6 +200,8 @@ public:
 
     virtual bool viewResizesToContentsEnabled() const { return viewResizesToContents; }
 
+    virtual void setWidgetVisible(Widget*, bool);
+
     void createOrDeleteOverlay();
 
 #if USE(TILED_BACKING_STORE)
index 22e7ea7..3fa9c45 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-14  Simon Hausmann  <simon.hausmann@nokia.com>
+
+        [Qt] Eliminate first set of QtWidgets dependencies from WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=78611
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * UIProcess/qt/QtWebPageEventHandler.cpp: Add missing QCursor include
+        to fix compilation.
+
 2012-02-15  Roland Steiner  <rolandsteiner@chromium.org>
 
         <style scoped>: Allow <style scoped> as a direct child of a ShadowRoot
index feba82f..72b96ba 100644 (file)
@@ -27,6 +27,7 @@
 #include "QtViewportInteractionEngine.h"
 #include "qquickwebpage_p.h"
 #include "qquickwebview_p.h"
+#include <QCursor>
 #include <QDrag>
 #include <QGraphicsSceneMouseEvent>
 #include <QGuiApplication>