summaryrefslogtreecommitdiffstats
path: root/WebKitTools/MiniBrowser/qt
diff options
context:
space:
mode:
authorLeon Clarke <leonclarke@google.com>2010-07-15 12:03:35 +0100
committerLeon Clarke <leonclarke@google.com>2010-07-20 16:57:23 +0100
commite458d70a0d18538346f41b503114c9ebe6b2ce12 (patch)
tree86f1637deca2c524432a822e5fcedd4bef221091 /WebKitTools/MiniBrowser/qt
parentf43eabc081f7ce6af24b9df4953498a3cd6ca24d (diff)
downloadexternal_webkit-e458d70a0d18538346f41b503114c9ebe6b2ce12.zip
external_webkit-e458d70a0d18538346f41b503114c9ebe6b2ce12.tar.gz
external_webkit-e458d70a0d18538346f41b503114c9ebe6b2ce12.tar.bz2
Merge WebKit at r63173 : Initial merge by git.
Change-Id: Ife5af0c7c6261fbbc8ae6bc08c390efa9ef10b44
Diffstat (limited to 'WebKitTools/MiniBrowser/qt')
-rw-r--r--WebKitTools/MiniBrowser/qt/BrowserWindow.cpp118
-rw-r--r--WebKitTools/MiniBrowser/qt/BrowserWindow.h72
-rw-r--r--WebKitTools/MiniBrowser/qt/MiniBrowser.pro45
-rw-r--r--WebKitTools/MiniBrowser/qt/main.cpp42
4 files changed, 277 insertions, 0 deletions
diff --git a/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp b/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp
new file mode 100644
index 0000000..1196cc4
--- /dev/null
+++ b/WebKitTools/MiniBrowser/qt/BrowserWindow.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2010 University of Szeged
+ *
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "BrowserWindow.h"
+#include <WebKit2/WKPageNamespace.h>
+#include <WebKit2/qwkpage.h>
+
+static QWKPage* createNewPage(QWKPage* page)
+{
+ return page;
+}
+
+BrowserView::BrowserView(QWidget* parent)
+ : QGraphicsView(parent)
+ , m_item(0)
+{
+ m_context.adopt(WKContextGetSharedProcessContext());
+
+ WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(m_context.get()));
+
+ m_item = new QGraphicsWKView(pageNamespace.get(), QGraphicsWKView::Simple, 0);
+ setScene(new QGraphicsScene(this));
+ scene()->addItem(m_item);
+
+ setFrameShape(QFrame::NoFrame);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ connect(m_item, SIGNAL(titleChanged(QString)), this, SLOT(setWindowTitle(QString)));
+ m_item->page()->setCreateNewPageFunction(createNewPage);
+}
+
+void BrowserView::resizeEvent(QResizeEvent* event)
+{
+ QGraphicsView::resizeEvent(event);
+ QRectF rect(QPoint(0, 0), event->size());
+ m_item->setGeometry(rect);
+ scene()->setSceneRect(rect);
+}
+
+void BrowserView::load(const QUrl& url)
+{
+ m_item->load(url);
+}
+
+QGraphicsWKView* BrowserView::view() const
+{
+ return m_item;
+}
+
+BrowserWindow::BrowserWindow()
+{
+ m_menu = new QMenuBar();
+ m_browser = new BrowserView();
+ m_addressBar = new QLineEdit();
+
+ m_menu->addAction("Quit", this, SLOT(close()));
+
+ m_browser->setFocus(Qt::OtherFocusReason);
+
+ connect(m_addressBar, SIGNAL(returnPressed()), SLOT(changeLocation()));
+
+ QToolBar* bar = addToolBar("Navigation");
+ bar->addAction(m_browser->view()->page()->action(QWKPage::Back));
+ bar->addAction(m_browser->view()->page()->action(QWKPage::Forward));
+ bar->addAction(m_browser->view()->page()->action(QWKPage::Reload));
+ bar->addAction(m_browser->view()->page()->action(QWKPage::Stop));
+ bar->addWidget(m_addressBar);
+
+ this->setMenuBar(m_menu);
+ this->setCentralWidget(m_browser);
+
+ m_browser->setFocus(Qt::OtherFocusReason);
+}
+
+void BrowserWindow::load(const QString& url)
+{
+ m_addressBar->setText(url);
+ m_browser->load(QUrl(url));
+}
+
+void BrowserWindow::changeLocation()
+{
+ QString string = m_addressBar->text();
+ m_browser->load(string);
+}
+
+BrowserWindow::~BrowserWindow()
+{
+ delete m_addressBar;
+ delete m_browser;
+ delete m_menu;
+}
diff --git a/WebKitTools/MiniBrowser/qt/BrowserWindow.h b/WebKitTools/MiniBrowser/qt/BrowserWindow.h
new file mode 100644
index 0000000..30c5122
--- /dev/null
+++ b/WebKitTools/MiniBrowser/qt/BrowserWindow.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2010 University of Szeged
+ *
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#define PLATFORM(x) 0
+
+#include <stdint.h>
+#include <QtGui>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKContext.h>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+#include <WebKit2/qgraphicswkview.h>
+
+class BrowserView : public QGraphicsView {
+ Q_OBJECT
+
+public:
+ BrowserView(QWidget* parent = 0);
+ virtual ~BrowserView() { delete m_item; }
+
+ void load(const QUrl&);
+ QGraphicsWKView* view() const;
+
+protected:
+ virtual void resizeEvent(QResizeEvent*);
+
+private:
+ QGraphicsWKView* m_item;
+ WKRetainPtr<WKContextRef> m_context;
+};
+
+class BrowserWindow : public QMainWindow {
+ Q_OBJECT
+
+public:
+ BrowserWindow();
+ ~BrowserWindow();
+ void load(const QString& url);
+
+protected slots:
+ void changeLocation();
+
+private:
+ BrowserView* m_browser;
+ QMenuBar* m_menu;
+ QLineEdit* m_addressBar;
+};
diff --git a/WebKitTools/MiniBrowser/qt/MiniBrowser.pro b/WebKitTools/MiniBrowser/qt/MiniBrowser.pro
new file mode 100644
index 0000000..9a57d1b
--- /dev/null
+++ b/WebKitTools/MiniBrowser/qt/MiniBrowser.pro
@@ -0,0 +1,45 @@
+TEMPLATE = app
+TARGET = MiniBrowser
+
+SOURCES += \
+ main.cpp \
+ BrowserWindow.cpp \
+
+HEADERS += \
+ BrowserWindow.h \
+
+CONFIG += uitools
+
+isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../..
+include(../../../WebKit.pri)
+
+INCLUDEPATH += $$OUTPUT_DIR/include
+
+DESTDIR = $$OUTPUT_DIR/bin
+!CONFIG(standalone_package): CONFIG -= app_bundle
+
+QT += network
+macx:QT+=xml
+
+linux-* {
+ # From Creator's src/rpath.pri:
+ # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR
+ # this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var.
+ QMAKE_RPATHDIR = \$\$ORIGIN/../lib $$QMAKE_RPATHDIR
+ MY_RPATH = $$join(QMAKE_RPATHDIR, ":")
+
+ QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\'
+ QMAKE_RPATHDIR =
+} else {
+ QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
+}
+
+symbian {
+ TARGET.UID3 = 0xA000E543
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
+
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+ DEFINES += QT_CONFIGURED_WITH_OPENGL
+}
diff --git a/WebKitTools/MiniBrowser/qt/main.cpp b/WebKitTools/MiniBrowser/qt/main.cpp
new file mode 100644
index 0000000..b261397
--- /dev/null
+++ b/WebKitTools/MiniBrowser/qt/main.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include <QtGui>
+#include "BrowserWindow.h"
+
+int main(int argc, char** argv) {
+ QApplication app(argc, argv);
+
+ BrowserWindow window;
+ window.resize(960, 640);
+ window.show();
+ window.load(argc > 1 ? argv[1] : "http://www.google.com");
+
+ app.exec();
+
+ return 0;
+}