summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/qt/docs
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/qt/docs')
-rw-r--r--Source/WebKit/qt/docs/docs.pri15
-rw-r--r--Source/WebKit/qt/docs/qtwebkit-bridge.qdoc423
-rw-r--r--Source/WebKit/qt/docs/qtwebkit.qdoc190
-rw-r--r--Source/WebKit/qt/docs/qtwebkit.qdocconf197
-rw-r--r--Source/WebKit/qt/docs/qwebview-diagram.pngbin0 -> 9036 bytes
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp174
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc8
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp15
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp35
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/simple/main.cpp34
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/simple/simple.pro2
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/webelement/main.cpp125
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro8
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/webpage/main.cpp81
-rw-r--r--Source/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro3
15 files changed, 1310 insertions, 0 deletions
diff --git a/Source/WebKit/qt/docs/docs.pri b/Source/WebKit/qt/docs/docs.pri
new file mode 100644
index 0000000..d87dcd6
--- /dev/null
+++ b/Source/WebKit/qt/docs/docs.pri
@@ -0,0 +1,15 @@
+include(../../../../WebKit.pri)
+
+unix {
+ QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/bin/qdoc3
+} else {
+ QDOC = $$(QTDIR)\\bin\\qdoc3.exe
+}
+
+unix {
+docs.commands = $$QDOC $$PWD/qtwebkit.qdocconf
+} else {
+docs.commands = \"$$QDOC $$PWD/qtwebkit.qdocconf\"
+}
+
+QMAKE_EXTRA_TARGETS += docs
diff --git a/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc b/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc
new file mode 100644
index 0000000..0947a0a
--- /dev/null
+++ b/Source/WebKit/qt/docs/qtwebkit-bridge.qdoc
@@ -0,0 +1,423 @@
+/*!
+ \inmodule QtWebKit
+ \page qtwebkit-bridge.html
+ \title The QtWebKit Bridge
+ \contentspage QtWebKit
+ \section1 Overview
+ \section2 The technology
+
+ The QtWebKit bridge is a mechanism that extends WebKit's JavaScript environment to access native
+ objects represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection,
+ a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment.
+ For example \l{QObject} properties map directly to JavaScript properties.
+
+ \section2 Use Cases
+
+ There are two main use cases for the QtWebKit bridge: web content in native applications and thin clients.
+
+ \section3 Web Content in Native Applications
+
+ This is a common use case in classic Qt application, and a design pattern used by several modern
+ applications like an application that contains a media-player, playlist manager, and music store.
+ The playlist manager is usually best authored as a classic desktop application,
+ with the native-looking robust \l{QWidget}s as the application's backbone.
+ The media-player control usually has a custom look and feel and is best written using the \l{Graphics View framework}
+ or \l{QtDeclarative}. The music store, which shows dynamic content
+ from the Internet and gets modified rapidly, is best authored in HTML and maintained on the server.
+
+ With the QtWebKit bridge, the music store component can interact with native parts of the application,
+ for example, when a file needs to be saved to a specific location.
+
+ \section3 Thin Clients
+
+ The use case uses Qt as a native backend of a full web application,
+ a so-called thin client. In this use case, the entire UI is driven by
+ HTML, JavaScript and CSS. Additionally, it uses Qt-based components to
+ access native features usually not exposed to the web, or to enable helper
+ components that are best written in C++.
+
+ An example for such a client is a UI for a video-on-demand service on a TV. The entire content and
+ UI can be kept on the server, served dynamically through HTTP and rendered with WebKit. Additional
+ native components are used to access hardware-specific features like extracting a list of images
+ out of a video stream.
+
+ \section2 Difference from Other Bridge Technologies
+
+ Of course, QtWebKit is not the only bridge technology out there. NPAPI, for example,
+ is a long-time standard for web-native bridging. Due to Qt's meta-object system, full applications
+ leveraging web technologies are much easier to develop with the QtWebKit bridge than with NPAPI. NPAPI, however, is better
+ for cross-browser plugins, due to it being an accepted standard.
+
+ When developing a plugin for a browser, NPAPI is recommended. When developing a full application
+ utilizing HTML-rendering, the QtWebKit bridge is recommended.
+
+ \section2 Relationship with QtScript
+
+ The QtWebKit bridge is similar to \l{QtScript}, especially for some of the features described in the
+ \l{Making Applications Scriptable} page. However, Qt 4.7 does not provide the full QtScript API for web applications.
+ Full support is planned for future versions. You might notice that some of the features
+ described here are an exact copy of the ones described in the \l{Making Applications Scriptable} page. That is because
+ the QtWebKit bridge is a subset of that functionality, and this page tries to capture the full
+ capabilities available through the QtWebKit bridge specifically.
+
+ \section1 Accessing QObjects
+
+ \section2 Making QObjects known to JavaScript via QWebFrame
+
+ By default, no QObjects are accessible through the web environment, for security reasons.
+ When a web application wants to access a native QObject, it must explicitly grant access
+ to this QObject, using the following call:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 0
+
+ See \l{QWebFrame::addToJavaScriptWindowObject()} for more information.
+
+ \section2 Using Signals and Slots
+
+ The QtWebKit bridge adapts Qt's central \l{Signals and Slots} feature for
+ scripting. There are three principal ways to use signals and slots
+ with the QtWebKit bridge:
+
+ \list
+ \i \bold{Hybrid C++/script}: C++ application code connects a
+ signal to a script function. This approach is useful if you have
+ a QObject but don't want to expose the object itself to the scripting
+ environment. You just want to define how the script responds to a
+ signal and leave it up to the C++ side of your application to establish
+ the connection between the C++ signal and the JavaScript slot.
+
+ \i \bold{Hybrid script/C++}: A script can connect signals and slots
+ to establish connections between pre-defined objects that the
+ application exposes to the scripting environment. In this scenario,
+ the slots themselves are still written in C++, but the definition of
+ the connections is fully dynamic (script-defined).
+
+ \i \bold{Purely script-defined}: A script can both define signal
+ handler functions (effectively "slots written in JavaScript"),
+ \e{and} set up the connections that utilize those handlers. For
+ example, a script can define a function that will handle the
+ QLineEdit::returnPressed() signal, and then connect that signal to the
+ script function.
+ \endlist
+
+ Note that QtScript functions such as qScriptConnect are unavilable in the web environment.
+
+ \section3 Signal to Function Connections
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 7
+
+ The call to \c{connect()} establishes a connection between the signal
+ \c{somethingChanged} and the slot \c{myInterestingScriptFunction}.
+ Whenever the object \c{myObject} emits the signal \c{somethingChanged},
+ the slot \c{myInterestingScriptFunction} gets called automatically.
+
+ The argument of \c{connect()} can be any JavaScript function as in the above
+ example or a slot of a QObject as in the following example:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 8
+
+ When the argument is a slot of a QObject, the argument types of the
+ signal and the slot do not have to be compatible. If possible, the QtWebKit
+ bridge converts the signal arguments such that they match the slot argument.
+
+ To disconnect a slot from a signal, you call the signal's
+ \c{disconnect()} function with the slot as its argument:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 9
+
+ When a script function is invoked in response to a signal, the
+ \c this object will be the Global Object.
+
+ \section3 Signal to Member Function Connections
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 10
+
+ The call to \c{connect() establishes a connection between the signal
+ \c{somethingChanged} and the slot \c{function}. Whenever the object
+ \c{myObject} emits the signal \c{somethingChanged}, the slot \c{function}
+ of the object \c{thisObject} gets called automatically. Let's illustrate
+ this with an example.
+
+ If you have a push button in a form, you typically want the form
+ to do something in response to the button's \c{clicked} signal. The
+ call to \c{connect()} makes sure that the function \c{onClicked()} is
+ called whenever you click on the push button, that is, whenever the
+ the signal \c{clicked()} is emitted by \c{myButton}. The slot \c{onClicked()}
+ prints the value of \c{x} as stored in the \c{form}.
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 11
+
+ To disconnect a slot from a signal, you pass the same arguments to
+ \c{disconnect()} as you passed to \c{connect()}. In general, this looks
+ as follows:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 12
+
+ \section3 Signal to Named Member Function Connections
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 14
+
+ This form of the \c{connect()} function requires that the first argument \c{thisObject} is
+ the object that will be bound to \c{this} when the function \c{functionName} is
+ invoked in response to the signal \c{somethingChanged}. The second argument \c{functionName} specifies the
+ name of a function that is connected to the signal. It refers to a
+ member function of the object \c{thisObject}.
+
+ Note that the function is resolved when the connection is made, not
+ when the signal is emitted.
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 15
+
+ To disconnect from the signal, pass the same arguments to \c{disconnect()}
+ as you passed to \c{connect}:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 17
+
+ \section3 Error Handling
+
+ When \c{connect()} or \c{disconnect()} succeeds, the function will
+ return \c{undefined}; otherwise, it will throw a script exception.
+ You can obtain an error message from the resulting \c{Error} object.
+ Example:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 18
+
+ \section3 Emitting Signals from Scripts
+
+ To emit a signal from script code, you simply invoke the signal
+ function, passing the relevant arguments:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 19
+
+ It is currently not possible to define a new signal in a script;
+ i.e., all signals must be defined by C++ classes.
+
+ \section3 Overloaded Signals and Slots
+
+ When a signal or slot is overloaded, the QtWebKit bridge will attempt to
+ pick the right overload based on the actual types of the QScriptValue arguments
+ involved in the function invocation. For example, if your class has slots
+ \c{myOverloadedSlot(int)} and \c{myOverloadedSlot(QString)}, the following
+ script code will behave reasonably:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 20
+
+ You can specify a particular overload by using array-style property access
+ with the \l{QMetaObject::normalizedSignature()}{normalized signature} of
+ the C++ function as the property name:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 21
+
+ If the overloads have different number of arguments, the QtWebKit bridge will
+ pick the overload with the argument count that best matches the
+ actual number of arguments passed to the slot.
+
+ For overloaded signals, JavaScript will throw an error if you try to connect
+ to the signal by name; you have to refer to the signal with the full
+ normalized signature of the particular overload you want to connect to.
+
+ \section3 Invokable Methods
+
+ Both slots and signals are invokable from scripts by default. In addition, it is also
+ possible to define a method that is invokable from scripts, although the method is neither a signal nor a slot.
+ This is especially useful for functions with return types, as slots normally do not return anything
+ (it would be meaningless to return a value from a slot, as the connected signals cannot handle return values).
+ To make a non-slot method invokable, simply add the Q_INVOKABLE macro before its definition:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 22
+
+ \section2 Accessing Properties
+
+ The properties of a QObject are available as properties
+ of the corresponding JavaScript object. When you manipulate
+ a property in script code, the C++ get/set method for that
+ property will automatically be invoked. For example, if your
+ C++ class has a property declared as follows:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 23
+
+ then script code can do things like the following:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 24
+
+ \section2 Accessing Child QObjects
+
+ Every named child of a QObject (that is, every child for which
+ QObject::objectName() does not return the empty string) is by default available as
+ a property of the JavaScript wrapper object. For example,
+ if you have a QDialog with a child widget whose \c{objectName} property is
+ \c{"okButton"}, you can access this object in script code through
+ the expression
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 25
+
+ Because \c{objectName} is itself a Q_PROPERTY, you can manipulate
+ the name in script code to rename an object. For example:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 26
+
+ \section2 Data types
+
+ When calling slots, receiving signals or accessing properties, usually some payload is involved.
+ For example, a property "text" might return a \l{QString} parameter.
+ The QtWebKit bridge does the job of converting between a given JavaScript data-type, and the
+ expected or given Qt type. Each Qt type has a coresponding set of rules of how JavaScript treats it.
+
+ The data type conversions are also applicable for the data returned from non-void invokable methods.
+
+ \section3 Numbers
+
+ All Qt numeric data types are converted to or from a JavaScript number. These include int, short, float,
+ double, and the portable Qt types (qreal, qint etc). A special case is \l{QChar}.
+ If a slot expects a QChar, the QtWebKit bridge uses the Unicode value in case of a number and the first character in case of a string.
+
+ Note that non-standard (typedef'ed) number types are not automatically converted to
+ or from a JavaScript number - we suggest to use standard number types for signals, slots
+ and properties.
+
+ When a non-number is passed as an argument to a method or property that expects a number,
+ the appropriate JavaScript conversion function (parseInt / parseFloat) is used.
+
+ \section3 Strings
+
+ When JavaScript accesses methods or properties that expect a \l{QString}, the QtWebKit bridge
+ will automatically convert the value to a string (if it is not already a string), using the
+ built-in JavaScript toString method.
+
+ When a QString is passed to JavaScript from a signal or a property, the QtWebKit bridge
+ converts it into a JavaScript string.
+
+ \section3 Date & Time
+
+ Both \l{QDate}, \l{QTime} and \l{QDateTime} are automatically translated to or from the JavaScript
+ Date object. If a number is passed as an argument to a method that expects one of the date/time
+ types, the QtWebKit bridge treats it as a timestamp. If a sting is passed, QtWebKit
+ tries the different Qt date parsing functions to perform the right translation.
+
+ \section3 Regular Expressions
+
+ The QtWebKit bridge automatically converts a JavaScript RegEx object to a \l{QRegExp}.
+ If a string is passed to a method expecting a \l{QRegExp}, the string is converted
+ to a \l{QRegExp}.
+
+ \section3 Lists
+
+ The QtWebKit bridge treats several types of lists in a special way: \l{QVariantList}, \l{QStringList},
+ \l{QObjectList} and \l{QList}<int>. When a slot or property expects one of those list types,
+ the QtWebKit bridge tries to convert a JavaScript array into that type, converting each of
+ the array's elements to the single-element type of the list.
+
+ The most useful type of list is \l{QVariantList}, which can be converted to and from any
+ JavaScript array.
+
+ \section3 Compound (JSON) objects
+
+ JavaScript compound objects, also known as JSON objects, are variables that hold a list
+ of key-value pairs, where all the keys are strings and the values can have any type.
+ This translates very well to \l{QVariantMap}, which is nothing more than a \l{QMap} from \l{QString}
+ to \l{QVariant}.
+
+ The seamless conversion between JSON objects and \l{QVariantMap} allows for a very convenient
+ way of passing arbitrary structured data between C++ and the JavaScript environment. If the native \l{QObject} makes sure that compound values are converted to \l{QVariantMap}s and \l{QVariantList}s, JavaScript is
+ guaranteed to receive them in a meaningful way.
+
+ Note that types that are not supported by JSON, such as JavaScript functions and getters/setters,
+ are not converted.
+
+ \section3 QVariants
+
+ When a slot or property accepts a \l{QVariant}, the QtWebKit bridge creates a \l{QVariant} that best
+ matches the argument passed by JavaScript. A string, for example, becomes a \l{QVariant} holding a \l{QString},
+ a normal JSON object becomes a \l{QVariantMap}, and a JavaScript array becomes a \l{QVariantList}.
+
+ Using \l{QVariant}s generously in C++ in that way makes C++ programming feel a bit more like JavaScript programming,
+ as it adds another level of indirection. Passing \l{QVariant}s around like this is very flexible. The program can figure out
+ the type of argument at runtime just like JavaScript would do. But doing so also takes away the type safety and robustness of C++.
+ We recommended to use \l{QVariant}s only for high-level functions, and to keep most of your
+ \l{QObject}s type-safe.
+
+ \section3 QObjects
+
+ Pointers to a \l{QObject} or a \l{QWidget} can be used in signals, slots and properties. This object
+ can then be used like an object that is exposed directly. Its slots can be invoked, its signals connected to, etc.
+ However, this functionality is fairly limited - the type used has to be \l{QObject}* or \l{QWidget}*. If the type
+ specified is a pointer to a non-\l{QWidget} subclass of \l{QObject}, the QtWebKit bridge does not recognize it as
+ a \l{QObject}.
+
+ In general its advised to use care when passing \l{QObject}s as arguments, as those objects don't become owned by
+ the JavaScript engine; That means that the application developer has to be extra careful not to try to access
+ \l{QObject}s that have already been deleted by the native environment.
+
+ \section3 Pixmaps and Images
+
+ \since 4.7
+
+ The QtWebKit bridge handles \l{QPixmap}s and \l{QImage}s in a special way. Since QtWebKit stores \l{QPixmap}s to
+ represent HTML images, \l{QPixmap}s coming from the native environment can be used directly inside WebKit.
+ A \l{QImage} or a \l{QPixmap} coming from Qt is converted to an intermediate JavaScript object,
+ which can be represented like this:
+
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 1
+
+ The JavaScript environment can then use the pixmap from Qt and display it inside the HTML environment,
+ by assigning it to an existing \c{<img>} element with \c{assignToHTMLImageElement()}. It can also use the \c{toDataURL()} function,
+ which allows using the pixmap as the \c{src} attribute of an image or as a \c{background-image} URL. Note that the \c{toDataURL()}
+ function is costly and should be used with caution.
+
+ Example code:
+
+ C++:
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 2
+
+ HTML:
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 3
+
+ When a Qt object expects a \l{QImage} or a \l{QPixmap} as input, and the argument passed is an HTML image element,
+ the QtWebKit bridge would convert the pixmap assigned to that image element into a \l{QPixmap} or a \l{QImage}.
+
+ \since 4.7
+
+ \section3 QWebElement
+
+ A signal, slot or property that expects or returns a \l{QWebElement} can work seamlessly with JavaScript references
+ to DOM elements. The JavaScript environment can select DOM elements, keep them in variables, then pass them to Qt as
+ a \l{QWebElement}, and receive them back. Example:
+
+ C++:
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 4
+
+ HTML:
+ \snippet webkitsnippets/qtwebkit_bridge_snippets.cpp 5
+
+ This is specifically useful to create custom renderers or extensions to the web environment. Instead of forcing Qt
+ to select the element, the web environment selects the element and then sends the selected element directly to Qt.
+
+ Note that \l{QWebElement}s are not thread safe - an object handling them has to live in the UI thread.
+
+ \section1 Architecture Issues
+
+ \section2 Limiting the Scope of the Hybrid Layer
+
+ When using QtWebKit's hybrid features, it is a common pitfall to make the API exposed to JavaScript very rich and
+ use all its features. This, however, leads to complexity and can create bugs that are hard to find.
+ Instead, it is advisable to keep the hybrid layer small and manageable: create a gate only when
+ there's an actual need for it, i.e. there's a new native enabler that requires a direct interface
+ to the application layer. Sometimes new functionality is better handled internally in the native layer
+ or in the web layer; simplicity is your friend.
+
+ This usually becomes more apparent when the hybrid layer can create or destroy objects, or uses
+ signals, slots or properties with a \l{QObject}* argument. It is advised to be very careful and to treat
+ an exposed \l{QObject} as a system - with careful attention to memory management and object ownership.
+
+ \section2 Internet Security
+
+ When exposing native objects to an open web environment, it is important to understand the security
+ implications. Think whether the exposed object enables the web environment access things that
+ shouldn't be open, and whether the web content loaded by that web page comes from a trusted source. In general, when
+ exposing native QObjects that give the web environment access to private information or to functionality
+ that's potentially harmful to the client, such exposure should be balanced by limiting the web page's
+ access to trusted URLs only with HTTPS, and by utilizing other measures as part of a security strategy.
+
+
+
+*/
diff --git a/Source/WebKit/qt/docs/qtwebkit.qdoc b/Source/WebKit/qt/docs/qtwebkit.qdoc
new file mode 100644
index 0000000..df22e65
--- /dev/null
+++ b/Source/WebKit/qt/docs/qtwebkit.qdoc
@@ -0,0 +1,190 @@
+/*!
+ \module QtWebKit
+ \title WebKit in Qt
+ \contentspage All Qt Modules
+ \previouspage QtSvg
+ \nextpage QtXml
+ \ingroup modules
+ \ingroup technology-apis
+
+ \brief The QtWebKit module provides a web browser engine as well as
+ classes to render and interact with web content.
+
+ QtWebKit provides a Web browser engine that makes it easy to embed content
+ from the World Wide Web into your Qt application. At the same time Web
+ content can be enhanced with native controls.
+
+ QtWebKit provides facilities for rendering of HyperText Markup Language
+ (HTML), Extensible HyperText Markup Language (XHTML) and Scalable Vector
+ Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) and
+ scripted with JavaScript.
+
+ A bridge between the JavaScript execution environment and the Qt object
+ model makes it possible for custom QObjects to be scripted. For detailed
+ documentation see \l{The QtWebkit Bridge}.
+ Integration with the Qt networking module enables Web pages to be transparently loaded
+ from Web servers, the local file system or even the Qt resource system.
+
+ In addition to providing pure rendering features, HTML documents can be
+ made fully editable to the user through the use of the \c{contenteditable}
+ attribute on HTML elements.
+
+ QtWebKit is based on the Open Source WebKit engine. More information about
+ WebKit itself can be found on the \l{WebKit Open Source Project} Web site.
+
+ \section1 Including In Your Project
+
+ To include the definitions of the module's classes, use the
+ following directive:
+
+ \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 1
+
+ To link against the module, add this line to your \l qmake \c
+ .pro file:
+
+ \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 0
+
+ \section1 Notes
+
+ \note Building the QtWebKit module with debugging symbols is problematic
+ on many platforms due to the size of the WebKit engine. We recommend
+ building the module only in release mode for embedded platforms.
+ Currently QtWebKit will always be compiled without debugging symbols
+ when using gcc. Take a look at the last lines of
+ \c{src/3rdparty/webkit/Source/WebCore/WebCore.pro} if you need to change this.
+
+ \note Web site icons, also known as "FavIcons", are currently not supported
+ on Windows. We plan to address this in a future release.
+
+ \note WebKit has certain minimum requirements that must be met on
+ Embedded Linux systems. See the \l{Qt for Embedded Linux Requirements}
+ document for more information.
+
+ \section1 Architecture
+
+ The easiest way to render content is through the QWebView class. As a
+ widget it can be embedded into your forms or a graphics view, and it
+ provides convenience functions for downloading and rendering web sites.
+
+ \snippet webkitsnippets/simple/main.cpp Using QWebView
+
+ QWebView is used to view Web pages. An instance of QWebView has one
+ QWebPage. QWebPage provides access to the document structure in a page,
+ describing features such as frames, the navigation history, and the
+ undo/redo stack for editable content.
+
+ HTML documents can be nested using frames in a frameset. An individual
+ frame in HTML is represented using the QWebFrame class. This class includes the
+ bridge to the JavaScript window object and can be painted using QPainter.
+ Each QWebPage has one QWebFrame object as its main frame, and the main frame
+ may contain many child frames.
+
+ Individual elements of an HTML document can be accessed via DOM JavaScript
+ interfaces from within a web page. The equivalent of this API in QtWebKit
+ is represented by QWebElement. QWebElement objects are obtained using QWebFrame's
+ \l{QWebFrame::}{findAllElements()} and \l{QWebFrame::}{findFirstElement()}
+ functions with CSS selector queries.
+
+ Common web browser features, defaults and other settings can be configured
+ through the QWebSettings class. It is possible to provide defaults for all
+ QWebPage instances through the default settings. Individual attributes
+ can be overidden by the page specific settings object.
+
+ \section1 Netscape Plugin Support
+
+ \note Netscape plugin support is only available on desktop platforms.
+
+ Since WebKit supports the Netscape Plugin API, Qt applications can display
+ Web pages that embed common plugins on platforms for which those plugins
+ are available. To enable plugin support, the user must have the appropriate
+ binary files for those plugins installed and the \l{QWebSettings::PluginsEnabled}
+ attribute must be enabled for the application.
+
+ The following locations are searched for plugins:
+
+ \table
+ \header \o Linux/Unix (X11) \o Windows
+ \row \o{1,3}
+ \list
+ \o \c{.mozilla/plugins} in the user's home directory
+ \o \c{.netscape/plugins} in the user's home directory
+ \o System locations, such as
+ \list
+ \o \c{/usr/lib/browser/plugins}
+ \o \c{/usr/local/lib/mozilla/plugins}
+ \o \c{/usr/lib/firefox/plugins}
+ \o \c{/usr/lib64/browser-plugins}
+ \o \c{/usr/lib/browser-plugins}
+ \o \c{/usr/lib/mozilla/plugins}
+ \o \c{/usr/local/netscape/plugins}
+ \o \c{/opt/mozilla/plugins}
+ \o \c{/opt/mozilla/lib/plugins}
+ \o \c{/opt/netscape/plugins}
+ \o \c{/opt/netscape/communicator/plugins}
+ \o \c{/usr/lib/netscape/plugins}
+ \o \c{/usr/lib/netscape/plugins-libc5}
+ \o \c{/usr/lib/netscape/plugins-libc6}
+ \o \c{/usr/lib64/netscape/plugins}
+ \o \c{/usr/lib64/mozilla/plugins}
+ \endlist
+ \o Locations specified by environment variables:
+ \list
+ \o \c{$MOZILLA_HOME/plugins}
+ \o \c{$MOZ_PLUGIN_PATH}
+ \o \c{$QTWEBKIT_PLUGIN_PATH}
+ \endlist
+ \endlist
+
+ \o
+ \list
+ \o The user's \c{Application Data\Mozilla\plugins} directory
+ \o Standard system locations of plugins for Quicktime, Flash, etc.
+ \endlist
+
+ \row
+ \raw HTML
+ <th class="qt-style">Mac OS X</th>
+ \endraw
+ \row
+ \o
+ \list
+ \o \c{Library/Internet Plug-Ins} in the user's home directory
+ \o The system \c{/Library/Internet Plug-Ins} directory
+ \endlist
+ \endtable
+
+
+ \section1 License Information
+
+ This is a snapshot of the Qt port of WebKit. The exact version information
+ can be found in the \c{src/3rdparty/webkit/VERSION} file supplied with Qt.
+
+ Qt Commercial Edition licensees that wish to distribute applications that
+ use the QtWebKit module need to be aware of their obligations under the
+ GNU Library General Public License (LGPL).
+
+ Developers using the Open Source Edition can choose to redistribute
+ the module under the appropriate version of the GNU LGPL.
+
+ \legalese
+ WebKit is licensed under the GNU Library General Public License.
+ Individual contributor names and copyright dates can be found
+ inline in the code.
+
+ 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.
+ \endlegalese
+*/
+
diff --git a/Source/WebKit/qt/docs/qtwebkit.qdocconf b/Source/WebKit/qt/docs/qtwebkit.qdocconf
new file mode 100644
index 0000000..f1d198d
--- /dev/null
+++ b/Source/WebKit/qt/docs/qtwebkit.qdocconf
@@ -0,0 +1,197 @@
+# Run qdoc from the directory that contains this file.
+
+project = qtwebkit
+description = "Qt WebKit API Documentation"
+
+headerdirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/declarative
+sourcedirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/docs $SRCDIR/Source/JavaScriptCore/qt/api $SRCDIR/WebKit/qt/declarative
+outputdir = $OUTPUT_DIR/doc/html
+outputformats = HTML
+sources.fileextensions = "*.cpp *.doc *.qdoc *.h"
+exampledirs = $SRCDIR/WebKit/qt/docs
+imagedirs = $SRCDIR/WebKit/qt/docs
+
+indexes = $QTDIR/doc/html/qt.index
+
+# macros.qdocconf
+
+macro.aring.HTML = "&aring;"
+macro.Auml.HTML = "&Auml;"
+macro.author = "\\bold{Author:}"
+macro.br.HTML = "<br />"
+macro.BR.HTML = "<br />"
+macro.aacute.HTML = "&aacute;"
+macro.eacute.HTML = "&eacute;"
+macro.iacute.HTML = "&iacute;"
+macro.gui = "\\bold"
+macro.hr.HTML = "<hr />"
+macro.key = "\\bold"
+macro.menu = "\\bold"
+macro.note = "\\bold{Note:}"
+macro.oslash.HTML = "&oslash;"
+macro.ouml.HTML = "&ouml;"
+macro.QA = "\\e{Qt Assistant}"
+macro.QD = "\\e{Qt Designer}"
+macro.QL = "\\e{Qt Linguist}"
+macro.param = "\\e"
+macro.raisedaster.HTML = "<sup>*</sup>"
+macro.reg.HTML = "<sup>&reg;</sup>"
+macro.return = "Returns"
+macro.starslash = "\\c{*/}"
+macro.uuml.HTML = "&uuml;"
+macro.mdash.HTML = "&mdash;"
+
+# compat.qdocconf
+
+alias.i = e
+alias.include = input
+
+macro.0 = "\\\\0"
+macro.b = "\\\\b"
+macro.n = "\\\\n"
+macro.r = "\\\\r"
+macro.i = "\\o"
+macro.i11 = "\\o{1,1}"
+macro.i12 = "\\o{1,2}"
+macro.i13 = "\\o{1,3}"
+macro.i14 = "\\o{1,4}"
+macro.i15 = "\\o{1,5}"
+macro.i16 = "\\o{1,6}"
+macro.i17 = "\\o{1,7}"
+macro.i18 = "\\o{1,8}"
+macro.i19 = "\\o{1,9}"
+macro.i21 = "\\o{2,1}"
+macro.i31 = "\\o{3,1}"
+macro.i41 = "\\o{4,1}"
+macro.i51 = "\\o{5,1}"
+macro.i61 = "\\o{6,1}"
+macro.i71 = "\\o{7,1}"
+macro.i81 = "\\o{8,1}"
+macro.i91 = "\\o{9,1}"
+macro.img = "\\image"
+macro.endquote = "\\endquotation"
+
+spurious = "Missing comma in .*" \
+ "Missing pattern .*"
+
+# Doxygen compatibility commands
+
+macro.see = "\\sa"
+macro.function = "\\fn"
+
+# qt-cpp-ignore.qdocconf
+
+Cpp.ignoretokens = QAXFACTORY_EXPORT \
+ QDESIGNER_COMPONENTS_LIBRARY \
+ QDESIGNER_EXTENSION_LIBRARY \
+ QDESIGNER_SDK_LIBRARY \
+ QDESIGNER_SHARED_LIBRARY \
+ QDESIGNER_UILIB_LIBRARY \
+ QM_EXPORT_CANVAS \
+ QM_EXPORT_DNS \
+ QM_EXPORT_DOM \
+ QM_EXPORT_FTP \
+ QM_EXPORT_HTTP \
+ QM_EXPORT_ICONVIEW \
+ QM_EXPORT_NETWORK \
+ QM_EXPORT_OPENGL \
+ QM_EXPORT_SQL \
+ QM_EXPORT_TABLE \
+ QM_EXPORT_WORKSPACE \
+ QM_EXPORT_XML \
+ QT_ASCII_CAST_WARN \
+ QT_ASCII_CAST_WARN_CONSTRUCTOR \
+ QT_BEGIN_HEADER \
+ QT_DESIGNER_STATIC \
+ QT_END_HEADER \
+ QT_FASTCALL \
+ QT_WIDGET_PLUGIN_EXPORT \
+ Q_COMPAT_EXPORT \
+ Q_CORE_EXPORT \
+ Q_EXPLICIT \
+ Q_EXPORT \
+ Q_EXPORT_CODECS_CN \
+ Q_EXPORT_CODECS_JP \
+ Q_EXPORT_CODECS_KR \
+ Q_EXPORT_PLUGIN \
+ Q_GFX_INLINE \
+ Q_GUI_EXPORT \
+ Q_GUI_EXPORT_INLINE \
+ Q_GUI_EXPORT_STYLE_CDE \
+ Q_GUI_EXPORT_STYLE_COMPACT \
+ Q_GUI_EXPORT_STYLE_MAC \
+ Q_GUI_EXPORT_STYLE_MOTIF \
+ Q_GUI_EXPORT_STYLE_MOTIFPLUS \
+ Q_GUI_EXPORT_STYLE_PLATINUM \
+ Q_GUI_EXPORT_STYLE_POCKETPC \
+ Q_GUI_EXPORT_STYLE_SGI \
+ Q_GUI_EXPORT_STYLE_WINDOWS \
+ Q_GUI_EXPORT_STYLE_WINDOWSXP \
+ QHELP_EXPORT \
+ Q_INLINE_TEMPLATE \
+ Q_INTERNAL_WIN_NO_THROW \
+ Q_NETWORK_EXPORT \
+ Q_OPENGL_EXPORT \
+ Q_OUTOFLINE_TEMPLATE \
+ Q_SQL_EXPORT \
+ Q_SVG_EXPORT \
+ Q_SCRIPT_EXPORT \
+ Q_TESTLIB_EXPORT \
+ Q_TYPENAME \
+ Q_XML_EXPORT \
+ Q_XMLSTREAM_EXPORT \
+ Q_XMLPATTERNS_EXPORT \
+ QDBUS_EXPORT \
+ QT_BEGIN_NAMESPACE \
+ QT_BEGIN_INCLUDE_NAMESPACE \
+ QT_END_NAMESPACE \
+ QT_END_INCLUDE_NAMESPACE \
+ PHONON_EXPORT \
+ EXTENSIONSYSTEM_EXPORT \
+ QWEBKIT_EXPORT
+Cpp.ignoredirectives = Q_DECLARE_HANDLE \
+ Q_DECLARE_INTERFACE \
+ Q_DECLARE_METATYPE \
+ Q_DECLARE_OPERATORS_FOR_FLAGS \
+ Q_DECLARE_PRIVATE \
+ Q_DECLARE_PUBLIC \
+ Q_DECLARE_SHARED \
+ Q_DECLARE_TR_FUNCTIONS \
+ Q_DECLARE_TYPEINFO \
+ Q_DISABLE_COPY \
+ QT_FORWARD_DECLARE_CLASS \
+ Q_DUMMY_COMPARISON_OPERATOR \
+ Q_ENUMS \
+ Q_FLAGS \
+ Q_INTERFACES \
+ __attribute__ \
+ K_DECLARE_PRIVATE \
+ PHONON_OBJECT \
+ PHONON_HEIR
+
+
+
+HTML.style = "" \
+ "h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }"\
+ "a:link { color: #004faf; text-decoration: none }"\
+ "a:visited { color: #672967; text-decoration: none }"\
+ "td.postheader { font-family: sans-serif }"\
+ "tr.address { font-family: sans-serif }"\
+ "body { background: #ffffff; color: black }"\
+ "table tr.odd { background: #f0f0f0; color: black; }"\
+ "table tr.even { background: #e4e4e4; color: black; }"\
+ "table.annotated th { padding: 3px; text-align: left }"\
+ "table.annotated td { padding: 3px; } "\
+ "table tr pre { padding-top: none; padding-bottom: none; padding-left: none; padding-right: none; border: none; background: none }"\
+ "tr.qt-style { background: #a2c511; color: black }"\
+ "body pre { padding: 0.2em; border: #e7e7e7 1px solid; background: #f1f1f1; color: black }"\
+ "span.preprocessor, span.preprocessor a { color: darkblue; }"\
+ "span.comment { color: darkred; font-style: italic }"\
+ "span.string,span.char { color: darkgreen; }"\
+ ".title { text-align: center }"\
+ ".subtitle { font-size: 0.8em }"\
+ ".small-subtitle { font-size: 0.65em }"
+
+HTML.postheader = ""
+
+HTML.footer = ""
diff --git a/Source/WebKit/qt/docs/qwebview-diagram.png b/Source/WebKit/qt/docs/qwebview-diagram.png
new file mode 100644
index 0000000..ada865e
--- /dev/null
+++ b/Source/WebKit/qt/docs/qwebview-diagram.png
Binary files differ
diff --git a/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp
new file mode 100644
index 0000000..75aa0a9
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp
@@ -0,0 +1,174 @@
+
+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/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc
new file mode 100644
index 0000000..d4fc2bd
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+QT += webkit
+//! [0]
+
+
+//! [1]
+#include <QtWebKit>
+//! [1]
diff --git a/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
new file mode 100644
index 0000000..07f1d45
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
@@ -0,0 +1,15 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+ // ...
+ QWebPage *page = new QWebPage;
+ // ...
+
+ QWebInspector *inspector = new QWebInspector;
+ inspector->setPage(page);
+//! [0]
+
+}
+
diff --git a/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp
new file mode 100644
index 0000000..f04cd29
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp
@@ -0,0 +1,35 @@
+
+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/Source/WebKit/qt/docs/webkitsnippets/simple/main.cpp b/Source/WebKit/qt/docs/webkitsnippets/simple/main.cpp
new file mode 100644
index 0000000..408630e
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/simple/main.cpp
@@ -0,0 +1,34 @@
+/*
+ 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/Source/WebKit/qt/docs/webkitsnippets/simple/simple.pro b/Source/WebKit/qt/docs/webkitsnippets/simple/simple.pro
new file mode 100644
index 0000000..61cd3bf
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/simple/simple.pro
@@ -0,0 +1,2 @@
+QT += webkit
+SOURCES = main.cpp
diff --git a/Source/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/Source/WebKit/qt/docs/webkitsnippets/webelement/main.cpp
new file mode 100644
index 0000000..b1781a6
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/webelement/main.cpp
@@ -0,0 +1,125 @@
+/*
+ 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/Source/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro b/Source/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro
new file mode 100644
index 0000000..8ca4b59
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro
@@ -0,0 +1,8 @@
+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/Source/WebKit/qt/docs/webkitsnippets/webpage/main.cpp b/Source/WebKit/qt/docs/webkitsnippets/webpage/main.cpp
new file mode 100644
index 0000000..393b16a
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/webpage/main.cpp
@@ -0,0 +1,81 @@
+/*
+ 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/Source/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro b/Source/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro
new file mode 100644
index 0000000..fcad03b
--- /dev/null
+++ b/Source/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro
@@ -0,0 +1,3 @@
+CONFIG += console
+QT += webkit
+SOURCES = main.cpp \ No newline at end of file