[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8

kenneth at webkit.org kenneth at webkit.org
Wed Feb 10 22:16:19 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 74f3e5edbdcbc8f5961d7f1a36ba56d90bec8d07
Author: kenneth at webkit.org <kenneth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 5 11:45:55 2010 +0000

    Rubberstamped by Oliver Hunt.
    
    [Qt] Make it possible to choose whether the launcher should
    use the traditional QWidget based QWebView or the newer
    QGraphics based QGraphicsWebView on a QGraphicsView.
    
    * QtLauncher/main.cpp:
    (LauncherWindow::LauncherWindow):
    (LauncherWindow::eventFilter):
    (LauncherWindow::loadStarted):
    (LauncherWindow::print):
    (LauncherWindow::screenshot):
    (LauncherWindow::setEditable):
    (LauncherWindow::setupUI):
    (main):
    * QtLauncher/webview.cpp:
    (WebViewGraphicsBased::WebViewGraphicsBased):
    (WebViewGraphicsBased::resizeEvent):
    (GraphicsWebView::mousePressEvent):
    (GraphicsWebView::contextMenuEvent):
    * QtLauncher/webview.h:
    (WebViewTraditional::WebViewTraditional):
    (GraphicsWebView::GraphicsWebView):
    (WebViewGraphicsBased::setPage):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 0fe7fdb..5f267b7 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -13,6 +13,33 @@
 
         Rubberstamped by Oliver Hunt.
 
+        [Qt] Make it possible to choose whether the launcher should
+        use the traditional QWidget based QWebView or the newer
+        QGraphics based QGraphicsWebView on a QGraphicsView.
+
+        * QtLauncher/main.cpp:
+        (LauncherWindow::LauncherWindow):
+        (LauncherWindow::eventFilter):
+        (LauncherWindow::loadStarted):
+        (LauncherWindow::print):
+        (LauncherWindow::screenshot):
+        (LauncherWindow::setEditable):
+        (LauncherWindow::setupUI):
+        (main):
+        * QtLauncher/webview.cpp:
+        (WebViewGraphicsBased::WebViewGraphicsBased):
+        (WebViewGraphicsBased::resizeEvent):
+        (GraphicsWebView::mousePressEvent):
+        (GraphicsWebView::contextMenuEvent):
+        * QtLauncher/webview.h:
+        (WebViewTraditional::WebViewTraditional):
+        (GraphicsWebView::GraphicsWebView):
+        (WebViewGraphicsBased::setPage):
+
+2010-02-04  Kenneth Rohde Christiansen  <kenneth at webkit.org>
+
+        Rubberstamped by Oliver Hunt.
+
         [Qt] QtLauncher cleanup.
 
         Refactor option handling out in utility functions and make the
diff --git a/WebKitTools/QtLauncher/main.cpp b/WebKitTools/QtLauncher/main.cpp
index e4d68ff..21723c2 100644
--- a/WebKitTools/QtLauncher/main.cpp
+++ b/WebKitTools/QtLauncher/main.cpp
@@ -70,6 +70,8 @@
 void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
 #endif
 
+static bool useGraphicsView = false;
+
 class LauncherWindow : public MainWindow {
     Q_OBJECT
 
@@ -85,8 +87,6 @@ public:
     bool eventFilter(QObject* obj, QEvent* event);
 #endif
 
-    QWebView* webView() const { return view; }
-
 protected slots:
     void loadStarted();
     void loadFinished();
@@ -121,7 +121,7 @@ private:
     QVector<int> zoomLevels;
     int currentZoom;
 
-    QWebView* view;
+    QWidget* m_view;
     WebInspector* inspector;
 
     QAction* formatMenuAction;
@@ -140,11 +140,20 @@ LauncherWindow::LauncherWindow(QString url)
     QSplitter* splitter = new QSplitter(Qt::Vertical, this);
     setCentralWidget(splitter);
 
-    view = new WebViewTraditional(splitter);
-    view->setPage(page());
+    resize(800, 600);
+
+    if (!useGraphicsView) {
+        WebViewTraditional* view = new WebViewTraditional(splitter);
+        view->setPage(page());
+        m_view = view;
+    } else {
+        WebViewGraphicsBased* view = new WebViewGraphicsBased(splitter);
+        view->setPage(page());
+        m_view = view;
+    }
 
 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
-    view->installEventFilter(this);
+    m_view->installEventFilter(this);
     touchMocking = false;
 #endif
 
@@ -238,7 +247,7 @@ void LauncherWindow::sendTouchEvent()
 
 bool LauncherWindow::eventFilter(QObject* obj, QEvent* event)
 {
-    if (!touchMocking || obj != view)
+    if (!touchMocking || obj != m_view)
         return QObject::eventFilter(obj, event);
 
     if (event->type() == QEvent::MouseButtonPress
@@ -290,7 +299,7 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event)
             touchPoint.setState(Qt::TouchPointPressed);
             touchPoint.setId(1);
             touchPoint.setScreenPos(QCursor::pos());
-            touchPoint.setPos(view->mapFromGlobal(QCursor::pos()));
+            touchPoint.setPos(m_view->mapFromGlobal(QCursor::pos()));
             touchPoint.setPressure(1);
             touchPoints.append(touchPoint);
             sendTouchEvent();
@@ -305,7 +314,7 @@ bool LauncherWindow::eventFilter(QObject* obj, QEvent* event)
 
 void LauncherWindow::loadStarted()
 {
-    view->setFocus(Qt::OtherFocusReason);
+    m_view->setFocus(Qt::OtherFocusReason);
 }
 
 void LauncherWindow::loadFinished()
@@ -362,14 +371,14 @@ void LauncherWindow::print()
 #if !defined(QT_NO_PRINTER)
     QPrintPreviewDialog dlg(this);
     connect(&dlg, SIGNAL(paintRequested(QPrinter*)),
-            view, SLOT(print(QPrinter*)));
+            m_view, SLOT(print(QPrinter*)));
     dlg.exec();
 #endif
 }
 
 void LauncherWindow::screenshot()
 {
-    QPixmap pixmap = QPixmap::grabWidget(view);
+    QPixmap pixmap = QPixmap::grabWidget(m_view);
     QLabel* label = new QLabel;
     label->setAttribute(Qt::WA_DeleteOnClose);
     label->setWindowTitle("Screenshot - Preview");
@@ -385,7 +394,7 @@ void LauncherWindow::screenshot()
 
 void LauncherWindow::setEditable(bool on)
 {
-    view->page()->setContentEditable(on);
+    page()->setContentEditable(on);
     formatMenuAction->setVisible(on);
 }
 
@@ -459,8 +468,8 @@ void LauncherWindow::setupUI()
     setEditable->setCheckable(true);
 
     QMenu* viewMenu = menuBar()->addMenu("&View");
-    viewMenu->addAction(view->pageAction(QWebPage::Stop));
-    viewMenu->addAction(view->pageAction(QWebPage::Reload));
+    viewMenu->addAction(page()->action(QWebPage::Stop));
+    viewMenu->addAction(page()->action(QWebPage::Reload));
     viewMenu->addSeparator();
     QAction* zoomIn = viewMenu->addAction("Zoom &In", this, SLOT(zoomIn()));
     QAction* zoomOut = viewMenu->addAction("Zoom &Out", this, SLOT(zoomOut()));
@@ -579,7 +588,6 @@ LauncherApplication::LauncherApplication(int& argc, char** argv)
     handleUserOptions();
 }
 
-static bool useGraphicsView = false;
 static void requiresGraphicsView(const QString& option)
 {
     if (useGraphicsView)
@@ -660,10 +668,9 @@ int main(int argc, char **argv)
     LauncherApplication app(argc, argv);
 
     if (app.isRobotized()) {
-        LauncherWindow* window = new LauncherWindow;
-        QWebView* view = window->webView();
-        UrlLoader loader(view->page()->mainFrame(), app.urls().at(0));
-        QObject::connect(view->page()->mainFrame(), SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext()));
+        LauncherWindow* window = new LauncherWindow();
+        UrlLoader loader(window->page()->mainFrame(), app.urls().at(0));
+        QObject::connect(window->page()->mainFrame(), SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext()));
         loader.loadNext();
         window->show();
         return launcherMain(app);
diff --git a/WebKitTools/QtLauncher/webview.cpp b/WebKitTools/QtLauncher/webview.cpp
index d08da4c..5201165 100644
--- a/WebKitTools/QtLauncher/webview.cpp
+++ b/WebKitTools/QtLauncher/webview.cpp
@@ -33,6 +33,26 @@
 #include "webview.h"
 
 #include <QtGui>
+#include <QGraphicsScene>
+
+WebViewGraphicsBased::WebViewGraphicsBased(QWidget* parent)
+    : QGraphicsView(parent)
+    , m_item(new GraphicsWebView)
+{
+    setScene(new QGraphicsScene);
+    scene()->addItem(m_item);
+
+    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+}
+
+void WebViewGraphicsBased::resizeEvent(QResizeEvent* event)
+{
+    QGraphicsView::resizeEvent(event);
+    QRectF rect(QPoint(0, 0), event->size());
+    m_item->setGeometry(rect);
+}
 
 static QMenu* createContextMenu(QWebPage* page, QPoint position)
 {
@@ -49,7 +69,7 @@ static QMenu* createContextMenu(QWebPage* page, QPoint position)
     return menu;
 }
 
-void WebViewGraphicsBased::mousePressEvent(QGraphicsSceneMouseEvent* event)
+void GraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* event)
 {
     setProperty("mouseButtons", QVariant::fromValue(int(event->buttons())));
     setProperty("keyboardModifiers", QVariant::fromValue(int(event->modifiers())));
@@ -65,7 +85,7 @@ void WebViewTraditional::mousePressEvent(QMouseEvent* event)
     QWebView::mousePressEvent(event);
 }
 
-void WebViewGraphicsBased::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
+void GraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
 {
     QMenu* menu = createContextMenu(page(), event->pos().toPoint());
     menu->exec(mapToScene(event->pos()).toPoint());
diff --git a/WebKitTools/QtLauncher/webview.h b/WebKitTools/QtLauncher/webview.h
index 68f220e..1d385c9 100644
--- a/WebKitTools/QtLauncher/webview.h
+++ b/WebKitTools/QtLauncher/webview.h
@@ -36,27 +36,43 @@
 #include "webpage.h"
 #include <qwebview.h>
 #include <qgraphicswebview.h>
+#include <QGraphicsView>
+#include <QGraphicsWidget>
 
-class WebViewGraphicsBased : public QGraphicsWebView {
+class WebViewTraditional : public QWebView {
+    Q_OBJECT
+
+public:
+    WebViewTraditional(QWidget* parent) : QWebView(parent) {}
+
+protected:
+    virtual void contextMenuEvent(QContextMenuEvent*);
+    virtual void mousePressEvent(QMouseEvent*);
+};
+
+
+class GraphicsWebView : public QGraphicsWebView {
     Q_OBJECT
 
 public:
-    WebViewGraphicsBased(QGraphicsItem* parent = 0) : QGraphicsWebView(parent) {};
+    GraphicsWebView(QGraphicsItem* parent = 0) : QGraphicsWebView(parent) {};
 
 protected:
     virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
     virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
 };
 
-class WebViewTraditional : public QWebView {
+
+class WebViewGraphicsBased : public QGraphicsView {
     Q_OBJECT
 
 public:
-    WebViewTraditional(QWidget* parent) : QWebView(parent) {}
+    WebViewGraphicsBased(QWidget* parent);
+    virtual void resizeEvent(QResizeEvent*);
+    void setPage(QWebPage* page) { m_item->setPage(page); }
 
-protected:
-    virtual void contextMenuEvent(QContextMenuEvent*);
-    virtual void mousePressEvent(QMouseEvent*);
+private:
+    GraphicsWebView* m_item;
 };
 
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list