summaryrefslogtreecommitdiffstats
path: root/WebKit/qt/docs/webkitsnippets
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /WebKit/qt/docs/webkitsnippets
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'WebKit/qt/docs/webkitsnippets')
-rw-r--r--WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp174
-rw-r--r--WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc8
-rw-r--r--WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp15
-rw-r--r--WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp35
-rw-r--r--WebKit/qt/docs/webkitsnippets/simple/main.cpp34
-rw-r--r--WebKit/qt/docs/webkitsnippets/simple/simple.pro2
-rw-r--r--WebKit/qt/docs/webkitsnippets/webelement/main.cpp125
-rw-r--r--WebKit/qt/docs/webkitsnippets/webelement/webelement.pro8
-rw-r--r--WebKit/qt/docs/webkitsnippets/webpage/main.cpp81
-rw-r--r--WebKit/qt/docs/webkitsnippets/webpage/webpage.pro3
10 files changed, 0 insertions, 485 deletions
diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp
deleted file mode 100644
index 75aa0a9..0000000
--- a/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-
-void wrapInFunction()
-{
-
- //! [0]
- // ...
- QWebFrame *frame = myWebPage->mainFrame();
- frame->addToJavaScriptWindowObject("someNameForMyObject", myObject);
- // ...
- //! [0]
-#if 0
- //! [1]
- {
- width: ...,
- height: ...,
- toDataURL: function() { ... },
- assignToHTMLImageElement: function(element) { ... }
- }
- //! [1]
-#endif
- //! [2]
- class MyObject : QObject {
- Q_OBJECT
- Q_PROPERTY(QPixmap myPixmap READ getPixmap)
-
- public:
- QPixmap getPixmap() const;
- };
-
- /* ... */
-
- MyObject myObject;
- myWebPage.mainFrame()->addToJavaScriptWindowObject("myObject", &myObject);
-
- //! [2]
-#if 0
- //! [3]
- <html>
- <head>
- <script>
- function loadImage()
- {
- myObject.myPixmap.assignToHTMLImageElement(document.getElementById("imageElement"));
- }
- </script>
- </head>
- <body onload="loadImage()">
- <img id="imageElement" width="300" height="200" />
- </body>
- </html>
-//! [3]
-#endif
-//! [4]
-class MyObject : QObject {
- Q_OBJECT
-
- public slots:
- void doSomethingWithWebElement(const QWebElement&);
- };
-
- /* ... */
-
- MyObject myObject;
- myWebPage.mainFrame()->addToJavaScriptWindowObject("myObject", &myObject);
-
- //! [4]
-#if 0
- //! [5]
- <html>
- <head>
- <script>
- function runExample() {
- myObject.doSomethingWithWebElement(document.getElementById("someElement"));
- }
- </script>
- </head>
- <body onload="runExample()">
- <span id="someElement">Text</span>
- </body>
- </html>
- //! [5]
- //! [6]
- connect(function);
- //! [6]
- //! [7]
- function myInterestingScriptFunction() { ... }
- ...
- myQObject.somethingChanged.connect(myInterestingScriptFunction);
- //! [7]
- //! [8]
- myQObject.somethingChanged.connect(myOtherQObject.doSomething);
- //! [8]
- //! [9]
- myQObject.somethingChanged.disconnect(myInterestingFunction);
- myQObject.somethingChanged.disconnect(myOtherQObject.doSomething);
- //! [9]
- //! [10]
- myQObject.somethingChanged.connect(thisObject, function)
- //! [10]
- //! [11]
- var form = { x: 123 };
- var onClicked = function() { print(this.x); };
- myButton.clicked.connect(form, onClicked);
- //! [11]
- //! [12]
- myQObject.somethingChanged.disconnect(thisObject, function);
- //! [12]
- //! [13]
- connect(function);
- //! [13]
- //! [14]
- myQObject.somethingChanged.connect(thisObject, "functionName")
- //! [14]
- //! [15]
- var obj = { x: 123, fun: function() { print(this.x); } };
- myQObject.somethingChanged.connect(obj, "fun");
- //! [15]
- //! [16]
- connect(function);
- //! [16]
- //! [17]
- myQObject.somethingChanged.disconnect(thisObject, "functionName");
- //! [17]
- //! [18]
- try {
- myQObject.somethingChanged.connect(myQObject, "slotThatDoesntExist");
- } catch (e) {
- print(e);
- }
- //! [18]
- //! [19]
- myQObject.somethingChanged("hello");
- //! [19]
- //! [20]
- myQObject.myOverloadedSlot(10); // will call the int overload
- myQObject.myOverloadedSlot("10"); // will call the QString overload
- //! [20]
- //! [21]
- myQObject['myOverloadedSlot(int)']("10"); // call int overload; the argument is converted to an int
- myQObject['myOverloadedSlot(QString)'](10); // call QString overload; the argument is converted to a string
- //! [21]
- //! [22]
- class MyObject : public QObject
- {
- Q_OBJECT
-
- public:
- Q_INVOKABLE void thisMethodIsInvokableInJavaScript();
- void thisMethodIsNotInvokableInJavaScript();
-
- ...
- };
- //! [22]
- //! [23]
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- //! [23]
- //! [24]
- myQObject.enabled = true;
-
- ...
-
- myQObject.enabled = !myQObject.enabled;
- //! [24]
- //! [25]
- myDialog.okButton
- //! [25]
- //! [26]
- myDialog.okButton
- myDialog.okButton.objectName = "cancelButton";
- // from now on, myDialog.cancelButton references the button
- //! [26]
-#endif
-}
-
diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc b/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc
deleted file mode 100644
index d4fc2bd..0000000
--- a/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc
+++ /dev/null
@@ -1,8 +0,0 @@
-//! [0]
-QT += webkit
-//! [0]
-
-
-//! [1]
-#include <QtWebKit>
-//! [1]
diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
deleted file mode 100644
index 07f1d45..0000000
--- a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-void wrapInFunction()
-{
-
-//! [0]
- // ...
- QWebPage *page = new QWebPage;
- // ...
-
- QWebInspector *inspector = new QWebInspector;
- inspector->setPage(page);
-//! [0]
-
-}
-
diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp
deleted file mode 100644
index f04cd29..0000000
--- a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-void wrapInFunction()
-{
-
-//! [0]
- view->page()->history();
-//! [0]
-
-
-//! [1]
- view->page()->settings();
-//! [1]
-
-
-//! [2]
- view->triggerAction(QWebPage::Copy);
-//! [2]
-
-
-//! [3]
- view->page()->triggerPageAction(QWebPage::Stop);
-//! [3]
-
-
-//! [4]
- view->page()->triggerPageAction(QWebPage::GoBack);
-//! [4]
-
-
-//! [5]
- view->page()->triggerPageAction(QWebPage::GoForward);
-//! [5]
-
-}
-
diff --git a/WebKit/qt/docs/webkitsnippets/simple/main.cpp b/WebKit/qt/docs/webkitsnippets/simple/main.cpp
deleted file mode 100644
index 408630e..0000000
--- a/WebKit/qt/docs/webkitsnippets/simple/main.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <QApplication>
-#include <QUrl>
-#include <QWebView>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- QWidget *parent = 0;
-//! [Using QWebView]
- QWebView *view = new QWebView(parent);
- view->load(QUrl("http://qt.nokia.com/"));
- view->show();
-//! [Using QWebView]
- return app.exec();
-}
diff --git a/WebKit/qt/docs/webkitsnippets/simple/simple.pro b/WebKit/qt/docs/webkitsnippets/simple/simple.pro
deleted file mode 100644
index 61cd3bf..0000000
--- a/WebKit/qt/docs/webkitsnippets/simple/simple.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-QT += webkit
-SOURCES = main.cpp
diff --git a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp
deleted file mode 100644
index b1781a6..0000000
--- a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <QApplication>
-#include <QUrl>
-#include <qwebview.h>
-#include <qwebframe.h>
-#include <qwebelement.h>
-
-static QWebFrame *frame;
-
-static void traverse()
-{
-//! [Traversing with QWebElement]
- frame->setHtml("<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>");
- QWebElement doc = frame->documentElement();
- QWebElement body = doc.firstChild();
- QWebElement firstParagraph = body.firstChild();
- QWebElement secondParagraph = firstParagraph.nextSibling();
-//! [Traversing with QWebElement]
-}
-
-static void findButtonAndClick()
-{
-
- frame->setHtml("<form name=\"myform\" action=\"submit_form.asp\" method=\"get\">"
- "<input type=\"text\" name=\"myfield\">"
- "<input type=\"submit\" value=\"Submit\">"
- "</form>");
-
-//! [Calling a DOM element method]
-
- QWebElement document = frame->documentElement();
- /* Assume that the document has the following structure:
-
- <form name="myform" action="submit_form.asp" method="get">
- <input type="text" name="myfield">
- <input type="submit" value="Submit">
- </form>
-
- */
-
- QWebElement button = document.findFirst("input[type=submit]");
- button.evaluateJavaScript("click()");
-
-//! [Calling a DOM element method]
-
- }
-
-static void autocomplete1()
-{
- QWebElement document = frame->documentElement();
-
-//! [autocomplete1]
- QWebElement firstTextInput = document.findFirst("input[type=text]");
- QString storedText = firstTextInput.attribute("value");
-//! [autocomplete1]
-
-}
-
-
-static void autocomplete2()
-{
-
- QWebElement document = frame->documentElement();
- QString storedText = "text";
-
-//! [autocomplete2]
- QWebElement firstTextInput = document.findFirst("input[type=text]");
- textInput.setAttribute("value", storedText);
-//! [autocomplete2]
-
-}
-
-
-static void findAll()
-{
-//! [FindAll]
- QWebElement document = frame->documentElement();
- /* Assume the document has the following structure:
-
- <p class=intro>
- <span>Intro</span>
- <span>Snippets</span>
- </p>
- <p>
- <span>Content</span>
- <span>Here</span>
- </p>
- */
-
-//! [FindAll intro]
- QWebElementCollection allSpans = document.findAll("span");
- QWebElementCollection introSpans = document.findAll("p.intro span");
-//! [FindAll intro] //! [FindAll]
-}
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- QWebView *view = new QWebView(0);
- frame = view->page()->mainFrame();
- traverse();
- findAll();
- findButtonAndClick();
- autocomplete1();
- autocomplete2();
- return 0;
-}
diff --git a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro
deleted file mode 100644
index 8ca4b59..0000000
--- a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-CONFIG -= app_bundle
-CONFIG(QTDIR_build) {
- QT += webkit
-}
-SOURCES = main.cpp
-include(../../../../../WebKit.pri)
-QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/docs/webkitsnippets/webpage/main.cpp b/WebKit/qt/docs/webkitsnippets/webpage/main.cpp
deleted file mode 100644
index 393b16a..0000000
--- a/WebKit/qt/docs/webkitsnippets/webpage/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <QtGui>
-#include <QWebPage>
-#include <QWebFrame>
-
-//! [0]
-class Thumbnailer : public QObject
-{
- Q_OBJECT
-
-public:
- Thumbnailer(const QUrl &url);
-
-signals:
- void finished();
-
-private slots:
- void render();
-
-private:
- QWebPage page;
-
-};
-//! [0]
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- Thumbnailer thumbnail(QUrl("http://qt.nokia.com"));
-
- QObject::connect(&thumbnail, SIGNAL(finished()),
- &app, SLOT(quit()));
-
- return app.exec();
-}
-
-//! [1]
-Thumbnailer::Thumbnailer(const QUrl &url)
-{
- page.mainFrame()->load(url);
- connect(&page, SIGNAL(loadFinished(bool)),
- this, SLOT(render()));
-}
-//! [1]
-
-//! [2]
-void Thumbnailer::render()
-{
- page.setViewportSize(page.mainFrame()->contentsSize());
- QImage image(page.viewportSize(), QImage::Format_ARGB32);
- QPainter painter(&image);
-
- page.mainFrame()->render(&painter);
- painter.end();
-
- QImage thumbnail = image.scaled(400, 400);
- thumbnail.save("thumbnail.png");
-
- emit finished();
-}
-//! [2]
-#include "main.moc"
diff --git a/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro b/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro
deleted file mode 100644
index fcad03b..0000000
--- a/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG += console
-QT += webkit
-SOURCES = main.cpp \ No newline at end of file