2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3 Copyright (C) 2007 Staikos Computing Services Inc.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #include "qwebframe.h"
24 #include "qwebpage_p.h"
25 #include "qwebframe_p.h"
26 #include "qwebsecurityorigin.h"
27 #include "qwebsecurityorigin_p.h"
29 #include "DocumentLoader.h"
30 #include "FocusController.h"
31 #include "FrameLoaderClientQt.h"
33 #include "FrameTree.h"
34 #include "FrameView.h"
35 #include "IconDatabase.h"
37 #include "PutPropertySlot.h"
38 #include "ResourceRequest.h"
39 #include "RenderView.h"
40 #include "SelectionController.h"
41 #include "Scrollbar.h"
42 #include "PrintContext.h"
43 #include "SubstituteData.h"
46 #include "RenderTreeAsText.h"
50 #include "RenderView.h"
51 #include "GraphicsContext.h"
52 #include "PlatformMouseEvent.h"
53 #include "PlatformWheelEvent.h"
54 #include "GraphicsContext.h"
55 #include "HitTestResult.h"
58 #include "runtime_object.h"
59 #include "runtime_root.h"
60 #include "JSDOMWindow.h"
61 #include "qt_instance.h"
62 #include "ScriptController.h"
63 #include "ScriptValue.h"
64 #include "JSDOMBinding.h"
65 #include "CallFrame.h"
68 #include "qt_runtime.h"
70 #include "wtf/HashMap.h"
74 #include <qfileinfo.h>
77 #if QT_VERSION >= 0x040400
78 #include <qnetworkrequest.h>
80 #include "qwebnetworkinterface.h"
84 #include "HTMLMetaElement.h"
87 using namespace WebCore;
89 // from text/qfont.cpp
91 extern Q_GUI_EXPORT int qt_defaultDpi();
94 void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebFrameData *frameData)
98 allowsScrolling = frameData->allowsScrolling;
99 marginWidth = frameData->marginWidth;
100 marginHeight = frameData->marginHeight;
102 frameLoaderClient = new FrameLoaderClientQt();
103 RefPtr<Frame> newFrame = Frame::create(webcorePage, frameData->ownerElement, frameLoaderClient);
104 frame = newFrame.get();
105 if (frameData->ownerElement)
106 frame->ref(); // balanced by adoptRef in FrameLoaderClientQt::createFrame
107 frameLoaderClient->setFrame(qframe, frame);
111 WebCore::Scrollbar* QWebFramePrivate::horizontalScrollBar() const
115 return frame->view()->horizontalScrollbar();
118 WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const
122 return frame->view()->verticalScrollbar();
128 \brief The QWebFrame class represents a frame in a web page.
130 QWebFrame represents a frame inside a web page. Each QWebPage
131 object contains at least one frame, the main frame, obtained using
132 QWebPage::mainFrame(). Additional frames will be created for HTML
133 \c{<frame>} or \c{<iframe>} elements.
135 A frame can be loaded using load() or setUrl(). Alternatively, if you have
136 the HTML content readily available, you can use setHtml() instead.
138 The page() function returns a pointer to the web page object. See
139 \l{Elements of QWebView} for an explanation of how web
140 frames are related to a web page and web view.
142 The title of an HTML frame can be accessed with the title() property.
143 Additionally, a frame may also specify an icon, which can be accessed
144 using the icon() property. If the title or the icon changes, the
145 corresponding titleChanged() and iconChanged() signals will be emitted.
146 The zoomFactor() property can be used to change the overall size
147 of the content displayed in the frame.
149 QWebFrame objects are created and controlled by the web page. You
150 can connect to the web page's \l{QWebPage::}{frameCreated()} signal
151 to be notified when a new frame is created.
153 The hitTestContent() function can be used to programmatically examine the
156 A QWebFrame can be printed onto a QPrinter using the print() function.
157 This function is marked as a slot and can be conveniently connected to
158 \l{QPrintPreviewDialog}'s \l{QPrintPreviewDialog::}{paintRequested()}
164 QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData)
166 , d(new QWebFramePrivate)
169 d->init(this, parent->d->page, frameData);
171 if (!frameData->url.isEmpty()) {
172 WebCore::ResourceRequest request(frameData->url, frameData->referrer);
173 d->frame->loader()->load(request, frameData->name);
177 QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
179 , d(new QWebFramePrivate)
181 d->page = parent->d->page;
182 d->init(this, parent->d->page->d->page, frameData);
185 QWebFrame::~QWebFrame()
187 if (d->frame && d->frame->loader() && d->frame->loader()->client())
188 static_cast<FrameLoaderClientQt*>(d->frame->loader()->client())->m_webFrame = 0;
194 Make \a object available under \a name from within the frame's JavaScript
195 context. The \a object will be inserted as a child of the frame's window
198 Qt properties will be exposed as JavaScript properties and slots as
201 If you want to ensure that your QObjects remain accessible after loading a
202 new URL, you should add them in a slot connected to the
203 javaScriptWindowObjectCleared() signal.
205 void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object)
207 JSC::JSLock lock(false);
208 JSDOMWindow *window = toJSDOMWindow(d->frame);
209 JSC::Bindings::RootObject *root = d->frame->script()->bindingRootObject();
211 qDebug() << "Warning: couldn't get window object";
215 JSC::ExecState* exec = window->globalExec();
217 JSC::JSObject *runtimeObject =
218 JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::QtInstance::getQtInstance(object, root));
220 JSC::PutPropertySlot slot;
221 window->put(exec, JSC::Identifier(exec, (const UChar *) name.constData(), name.length()), runtimeObject, slot);
225 Returns the frame's content, converted to HTML.
227 \sa setHtml(), toPlainText()
229 QString QWebFrame::toHtml() const
231 if (!d->frame->document())
233 return createMarkup(d->frame->document());
237 Returns the content of this frame converted to plain text.
241 QString QWebFrame::toPlainText() const
243 if (d->frame->view() && d->frame->view()->layoutPending())
244 d->frame->view()->layout();
246 Element *documentElement = d->frame->document()->documentElement();
247 return documentElement->innerText();
251 Returns a dump of the rendering tree. This is mainly useful for debugging
254 QString QWebFrame::renderTreeDump() const
256 if (d->frame->view() && d->frame->view()->layoutPending())
257 d->frame->view()->layout();
259 return externalRepresentation(d->frame->contentRenderer());
263 \property QWebFrame::title
264 \brief the title of the frame as defined by the HTML <title> element
269 QString QWebFrame::title() const
271 if (d->frame->document())
272 return d->frame->loader()->documentLoader()->title();
273 else return QString();
278 \brief Returns the meta data in this frame as a QMultiMap
280 The meta data consists of the name and content attributes of the
281 of the \c{<meta>} tags in the HTML document.
288 <meta name="description" content="This document is a tutorial about Qt development">
289 <meta name="keywords" content="Qt, WebKit, Programming">
295 Given the above HTML code the metaData() function will return a map with two entries:
299 \row \o "description"
300 \o "This document is a tutorial about Qt development"
302 \o "Qt, WebKit, Programming"
305 This function returns a multi map to support multiple meta tags with the same name attribute.
307 QMultiMap<QString, QString> QWebFrame::metaData() const
309 if(!d->frame->document())
310 return QMap<QString,QString>();
312 QMultiMap<QString,QString> map;
313 Document* doc = d->frame->document();
314 RefPtr<NodeList> list = doc->getElementsByTagName("meta");
315 unsigned len = list->length();
316 for (unsigned i = 0; i < len; i++) {
317 HTMLMetaElement* meta = static_cast<HTMLMetaElement*>(list->item(i));
318 map.insert(meta->name(), meta->content());
323 static inline QUrl ensureAbsoluteUrl(const QUrl &url)
325 if (!url.isRelative())
328 return QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath());
332 \property QWebFrame::url
333 \brief the url of the frame currently viewed
338 void QWebFrame::setUrl(const QUrl &url)
340 d->frame->loader()->begin(ensureAbsoluteUrl(url));
341 d->frame->loader()->end();
342 load(ensureAbsoluteUrl(url));
345 QUrl QWebFrame::url() const
347 return d->frame->loader()->url();
351 \property QWebFrame::icon
352 \brief the icon associated with this frame
354 \sa iconChanged(), QWebSettings::iconForUrl()
357 QIcon QWebFrame::icon() const
359 return QWebSettings::iconForUrl(d->frame->loader()->url());
363 The name of this frame as defined by the parent frame.
365 QString QWebFrame::frameName() const
367 return d->frame->tree()->name();
371 The web page that contains this frame.
373 QWebPage *QWebFrame::page() const
379 Loads \a url into this frame.
381 \note The view remains the same until enough data has arrived to display the new \a url.
383 \sa setUrl(), setHtml(), setContent()
385 void QWebFrame::load(const QUrl &url)
387 #if QT_VERSION < 0x040400
388 load(QWebNetworkRequest(ensureAbsoluteUrl(url)));
390 load(QNetworkRequest(ensureAbsoluteUrl(url)));
394 #if QT_VERSION < 0x040400
396 Loads a network request, \a req, into this frame.
398 \note The view remains the same until enough data has arrived to display the new url.
400 void QWebFrame::load(const QWebNetworkRequest &req)
402 if (d->parentFrame())
403 d->page->d->insideOpenCall = true;
405 QUrl url = ensureAbsoluteUrl(req.url());
406 QHttpRequestHeader httpHeader = req.httpHeader();
407 QByteArray postData = req.postData();
409 WebCore::ResourceRequest request(url);
411 QString method = httpHeader.method();
412 if (!method.isEmpty())
413 request.setHTTPMethod(method);
415 QList<QPair<QString, QString> > values = httpHeader.values();
416 for (int i = 0; i < values.size(); ++i) {
417 const QPair<QString, QString> &val = values.at(i);
418 request.addHTTPHeaderField(val.first, val.second);
421 if (!postData.isEmpty())
422 request.setHTTPBody(WebCore::FormData::create(postData.constData(), postData.size()));
424 d->frame->loader()->load(request);
426 if (d->parentFrame())
427 d->page->d->insideOpenCall = false;
433 Loads a network request, \a req, into this frame, using the method specified in \a
436 \a body is optional and is only used for POST operations.
438 \note The view remains the same until enough data has arrived to display the new \a url.
442 void QWebFrame::load(const QNetworkRequest &req,
443 QNetworkAccessManager::Operation operation,
444 const QByteArray &body)
446 if (d->parentFrame())
447 d->page->d->insideOpenCall = true;
449 QUrl url = ensureAbsoluteUrl(req.url());
451 WebCore::ResourceRequest request(url);
454 case QNetworkAccessManager::HeadOperation:
455 request.setHTTPMethod("HEAD");
457 case QNetworkAccessManager::GetOperation:
458 request.setHTTPMethod("GET");
460 case QNetworkAccessManager::PutOperation:
461 request.setHTTPMethod("PUT");
463 case QNetworkAccessManager::PostOperation:
464 request.setHTTPMethod("POST");
466 case QNetworkAccessManager::UnknownOperation:
471 QList<QByteArray> httpHeaders = req.rawHeaderList();
472 for (int i = 0; i < httpHeaders.size(); ++i) {
473 const QByteArray &headerName = httpHeaders.at(i);
474 request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName)));
478 request.setHTTPBody(WebCore::FormData::create(body.constData(), body.size()));
480 d->frame->loader()->load(request);
482 if (d->parentFrame())
483 d->page->d->insideOpenCall = false;
488 Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative
489 URLs in the document, such as referenced images or stylesheets.
491 When using this method WebKit assumes that external resources such as JavaScript programs or style
492 sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external
493 script can be specified through the charset attribute of the HTML script tag. It is also possible
494 for the encoding to be specified by web server.
498 void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl)
501 WebCore::ResourceRequest request(kurl);
502 const QByteArray utf8 = html.toUtf8();
503 WTF::RefPtr<WebCore::SharedBuffer> data = WebCore::SharedBuffer::create(utf8.constData(), utf8.length());
504 WebCore::SubstituteData substituteData(data, WebCore::String("text/html"), WebCore::String("utf-8"), kurl);
505 d->frame->loader()->load(request, substituteData);
509 Sets the content of this frame to the specified content \a data. If the \a mimeType argument
510 is empty it is currently assumed that the content is HTML but in future versions we may introduce
513 External objects referenced in the content are located relative to \a baseUrl.
517 void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
520 WebCore::ResourceRequest request(kurl);
521 WTF::RefPtr<WebCore::SharedBuffer> buffer = WebCore::SharedBuffer::create(data.constData(), data.length());
522 QString actualMimeType = mimeType;
523 if (actualMimeType.isEmpty())
524 actualMimeType = QLatin1String("text/html");
525 WebCore::SubstituteData substituteData(buffer, WebCore::String(actualMimeType), WebCore::String(), kurl);
526 d->frame->loader()->load(request, substituteData);
531 Returns the parent frame of this frame, or 0 if the frame is the web pages
534 This is equivalent to qobject_cast<QWebFrame*>(frame->parent()).
538 QWebFrame *QWebFrame::parentFrame() const
540 return d->parentFrame();
544 Returns a list of all frames that are direct children of this frame.
548 QList<QWebFrame*> QWebFrame::childFrames() const
550 QList<QWebFrame*> rc;
552 FrameTree *tree = d->frame->tree();
553 for (Frame *child = tree->firstChild(); child; child = child->tree()->nextSibling()) {
554 FrameLoader *loader = child->loader();
555 FrameLoaderClientQt *client = static_cast<FrameLoaderClientQt*>(loader->client());
557 rc.append(client->webFrame());
565 Returns the scrollbar policy for the scrollbar defined by \a orientation.
567 Qt::ScrollBarPolicy QWebFrame::scrollBarPolicy(Qt::Orientation orientation) const
569 if (orientation == Qt::Horizontal)
570 return d->horizontalScrollBarPolicy;
571 return d->verticalScrollBarPolicy;
575 Sets the scrollbar policy for the scrollbar defined by \a orientation to \a policy.
577 void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy)
579 Q_ASSERT((int)ScrollbarAuto == (int)Qt::ScrollBarAsNeeded);
580 Q_ASSERT((int)ScrollbarAlwaysOff == (int)Qt::ScrollBarAlwaysOff);
581 Q_ASSERT((int)ScrollbarAlwaysOn == (int)Qt::ScrollBarAlwaysOn);
583 if (orientation == Qt::Horizontal) {
584 d->horizontalScrollBarPolicy = policy;
585 if (d->frame->view())
586 d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy);
588 d->verticalScrollBarPolicy = policy;
589 if (d->frame->view())
590 d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy);
595 Sets the current \a value for the scrollbar with orientation \a orientation.
597 The scrollbar forces the \a value to be within the legal range: minimum <= value <= maximum.
599 Changing the value also updates the thumb position.
601 \sa scrollBarMinimum(), scrollBarMaximum()
603 void QWebFrame::setScrollBarValue(Qt::Orientation orientation, int value)
606 sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
610 else if (value > scrollBarMaximum(orientation))
611 value = scrollBarMaximum(orientation);
617 Returns the current value for the scrollbar with orientation \a orientation, or 0
618 if no scrollbar is found for \a orientation.
620 \sa scrollBarMinimum(), scrollBarMaximum()
622 int QWebFrame::scrollBarValue(Qt::Orientation orientation) const
625 sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
633 Returns the maximum value for the scrollbar with orientation \a orientation, or 0
634 if no scrollbar is found for \a orientation.
636 \sa scrollBarMinimum()
638 int QWebFrame::scrollBarMaximum(Qt::Orientation orientation) const
641 sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
643 return sb->maximum();
648 Returns the minimum value for the scrollbar with orientation \a orientation.
650 The minimum value is always 0.
652 \sa scrollBarMaximum()
654 int QWebFrame::scrollBarMinimum(Qt::Orientation orientation) const
661 Scrolls the frame \a dx pixels to the right and \a dy pixels downward. Both
662 \a dx and \a dy may be negative.
664 \sa QWebFrame::scrollOffset
667 void QWebFrame::scroll(int dx, int dy) const
669 if (!d->frame->view())
672 d->frame->view()->scrollBy(IntSize(dx, dy));
676 \property QWebFrame::scrollOffset
677 \brief The offset from the start this frame is currently scrolled to.
680 QPoint QWebFrame::scrollOffset() const
682 if (!d->frame->view())
685 IntSize ofs = d->frame->view()->scrollOffset();
686 return QPoint(ofs.width(), ofs.height());
689 void QWebFrame::setScrollOffset(const QPoint &offset) const
691 QPoint current = scrollOffset();
692 int dx = offset.x() - current.x();
693 int dy = offset.y() - current.y();
698 Render the frame into \a painter clipping to \a clip.
702 void QWebFrame::render(QPainter *painter, const QRegion &clip)
704 if (!d->frame->view() || !d->frame->contentRenderer())
707 d->frame->view()->layoutIfNeededRecursive();
709 GraphicsContext ctx(painter);
710 QVector<QRect> vector = clip.rects();
711 WebCore::FrameView* view = d->frame->view();
712 for (int i = 0; i < vector.size(); ++i) {
715 painter->setClipRect(vector.at(i), Qt::IntersectClip);
718 view->paint(&ctx, vector.at(i));
726 Render the frame into \a painter.
728 void QWebFrame::render(QPainter *painter)
730 if (!d->frame->view() || !d->frame->contentRenderer())
733 d->frame->view()->layoutIfNeededRecursive();
735 GraphicsContext ctx(painter);
736 WebCore::FrameView* view = d->frame->view();
737 view->paint(&ctx, view->frameRect());
741 \property QWebFrame::textSizeMultiplier
742 \brief the scaling factor for all text in the frame
745 Use setZoomFactor instead, in combination with the ZoomTextOnly attribute in
748 \note Setting this property also enables the ZoomTextOnly attribute in
753 Sets the value of the multiplier used to scale the text in a Web frame to
754 the \a factor specified.
756 void QWebFrame::setTextSizeMultiplier(qreal factor)
758 d->frame->setZoomFactor(factor, /*isTextOnly*/true);
762 Returns the value of the multiplier used to scale the text in a Web frame.
764 qreal QWebFrame::textSizeMultiplier() const
766 return d->frame->zoomFactor();
770 \property QWebFrame::zoomFactor
772 \brief the zoom factor for the frame
775 void QWebFrame::setZoomFactor(qreal factor)
777 d->frame->setZoomFactor(factor, d->frame->isZoomFactorTextOnly());
780 qreal QWebFrame::zoomFactor() const
782 return d->frame->zoomFactor();
786 Returns the position of the frame relative to it's parent frame.
788 QPoint QWebFrame::pos() const
790 if (!d->frame->view())
793 return d->frame->view()->frameRect().topLeft();
797 Return the geometry of the frame relative to it's parent frame.
799 QRect QWebFrame::geometry() const
801 if (!d->frame->view())
803 return d->frame->view()->frameRect();
807 \property QWebFrame::contentsSize
808 \brief the size of the contents in this frame
810 QSize QWebFrame::contentsSize() const
812 FrameView *view = d->frame->view();
815 return QSize(view->contentsWidth(), view->contentsHeight());
819 Performs a hit test on the frame contents at the given position \a pos and returns the hit test result.
821 QWebHitTestResult QWebFrame::hitTestContent(const QPoint &pos) const
823 if (!d->frame->view() || !d->frame->contentRenderer())
824 return QWebHitTestResult();
826 HitTestResult result = d->frame->eventHandler()->hitTestResultAtPoint(d->frame->view()->windowToContents(pos), /*allowShadowContent*/ false);
827 return QWebHitTestResult(new QWebHitTestResultPrivate(result));
832 bool QWebFrame::event(QEvent *e)
834 return QObject::event(e);
837 #ifndef QT_NO_PRINTER
839 Prints the frame to the given \a printer.
843 void QWebFrame::print(QPrinter *printer) const
845 const qreal zoomFactorX = printer->logicalDpiX() / qt_defaultDpi();
846 const qreal zoomFactorY = printer->logicalDpiY() / qt_defaultDpi();
848 PrintContext printContext(d->frame);
849 float pageHeight = 0;
851 QRect qprinterRect = printer->pageRect();
853 IntRect pageRect(0, 0,
854 int(qprinterRect.width() / zoomFactorX),
855 int(qprinterRect.height() / zoomFactorY));
857 printContext.begin(pageRect.width());
859 printContext.computePageRects(pageRect, /*headerHeight*/0, /*footerHeight*/0, /*userScaleFactor*/1.0, pageHeight);
863 if (printer->collateCopies() == true){
865 pageCopies = printer->numCopies();
867 docCopies = printer->numCopies();
871 int fromPage = printer->fromPage();
872 int toPage = printer->toPage();
873 bool ascending = true;
875 if (fromPage == 0 && toPage == 0) {
877 toPage = printContext.pageCount();
880 fromPage = qMax(1, fromPage);
881 toPage = qMin(printContext.pageCount(), toPage);
883 if (printer->pageOrder() == QPrinter::LastPageFirst) {
890 QPainter painter(printer);
891 painter.scale(zoomFactorX, zoomFactorY);
892 GraphicsContext ctx(&painter);
894 for (int i = 0; i < docCopies; ++i) {
897 for (int j = 0; j < pageCopies; ++j) {
898 if (printer->printerState() == QPrinter::Aborted
899 || printer->printerState() == QPrinter::Error) {
903 printContext.spoolPage(ctx, page - 1, pageRect.width());
904 if (j < pageCopies - 1)
919 if ( i < docCopies - 1)
925 #endif // QT_NO_PRINTER
928 Evaluate JavaScript defined by \a scriptSource using this frame as context.
930 \sa addToJavaScriptWindowObject(), javaScriptWindowObjectCleared()
932 QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource)
934 ScriptController *proxy = d->frame->script();
937 JSC::JSValue* v = proxy->evaluate(String(), 1, scriptSource);
940 rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
946 QWebSecurityOrigin QWebFrame::securityOrigin() const
948 QWebFrame* that = const_cast<QWebFrame*>(this);
949 QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(QWebFramePrivate::core(that)->document()->securityOrigin());
950 return QWebSecurityOrigin(priv);
953 WebCore::Frame* QWebFramePrivate::core(QWebFrame* webFrame)
955 return webFrame->d->frame;
958 QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
960 return static_cast<FrameLoaderClientQt*>(coreFrame->loader()->client())->webFrame();
965 \fn void QWebFrame::javaScriptWindowObjectCleared()
967 This signal is emitted whenever the global window object of the JavaScript
968 environment is cleared, e.g., before starting a new load.
970 If you intend to add QObjects to a QWebFrame using
971 addToJavaScriptWindowObject(), you should add them in a slot connected
972 to this signal. This ensures that your objects remain accessible when
977 \fn void QWebFrame::provisionalLoad()
982 \fn void QWebFrame::titleChanged(const QString &title)
984 This signal is emitted whenever the title of the frame changes.
985 The \a title string specifies the new title.
991 \fn void QWebFrame::urlChanged(const QUrl &url)
993 This signal is emitted with the URL of the frame when the frame's title is
994 received. The new URL is specified by \a url.
1000 \fn void QWebFrame::initialLayoutCompleted()
1002 This signal is emitted when the frame is laid out the first time.
1003 This is the first time you will see contents displayed on the frame.
1005 \note A frame can be laid out multiple times.
1009 \fn void QWebFrame::iconChanged()
1011 This signal is emitted when the icon ("favicon") associated with the frame
1019 \fn void QWebFrame::aboutToUpdateHistory(QWebHistoryItem* item);
1021 This signal is emitted shortly before the history of navigated pages
1022 is changed, for example when navigating back in the history.
1024 A potential use-case for this signal is to store custom data in
1025 the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData().
1029 \class QWebHitTestResult
1031 \brief The QWebHitTestResult class provides information about the web
1032 page content after a hit test.
1034 QWebHitTestResult is returned by QWebFrame::hitTestContent() to provide
1035 information about the content of the web page at the specified position.
1041 QWebHitTestResult::QWebHitTestResult(QWebHitTestResultPrivate *priv)
1046 QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest)
1047 : isContentEditable(false)
1048 , isContentSelected(false)
1050 if (!hitTest.innerNode())
1052 pos = hitTest.point();
1053 boundingRect = hitTest.boundingBox();
1054 title = hitTest.title();
1055 linkText = hitTest.textContent();
1056 linkUrl = hitTest.absoluteLinkURL();
1057 linkTitle = hitTest.titleDisplayString();
1058 alternateText = hitTest.altDisplayString();
1059 imageUrl = hitTest.absoluteImageURL();
1060 innerNonSharedNode = hitTest.innerNonSharedNode();
1061 WebCore::Image *img = hitTest.image();
1063 QPixmap *pix = img->nativeImageForCurrentFrame();
1067 WebCore::Frame *wframe = hitTest.targetFrame();
1069 linkTargetFrame = QWebFramePrivate::kit(wframe);
1071 isContentEditable = hitTest.isContentEditable();
1072 isContentSelected = hitTest.isSelected();
1074 if (innerNonSharedNode && innerNonSharedNode->document()
1075 && innerNonSharedNode->document()->frame())
1076 frame = QWebFramePrivate::kit(innerNonSharedNode->document()->frame());
1080 Constructs a null hit test result.
1082 QWebHitTestResult::QWebHitTestResult()
1088 Constructs a hit test result from \a other.
1090 QWebHitTestResult::QWebHitTestResult(const QWebHitTestResult &other)
1094 d = new QWebHitTestResultPrivate(*other.d);
1098 Assigns the \a other hit test result to this.
1100 QWebHitTestResult &QWebHitTestResult::operator=(const QWebHitTestResult &other)
1102 if (this != &other) {
1105 d = new QWebHitTestResultPrivate;
1118 QWebHitTestResult::~QWebHitTestResult()
1124 Returns true if the hit test result is null; otherwise returns false.
1126 bool QWebHitTestResult::isNull() const
1132 Returns the position where the hit test occured.
1134 QPoint QWebHitTestResult::pos() const
1143 Returns the bounding box of the element.
1145 QRect QWebHitTestResult::boundingRect() const
1149 return d->boundingRect;
1153 Returns the title of the nearest enclosing HTML element.
1155 QString QWebHitTestResult::title() const
1163 Returns the text of the link.
1165 QString QWebHitTestResult::linkText() const
1173 Returns the url to which the link points to.
1175 QUrl QWebHitTestResult::linkUrl() const
1183 Returns the title of the link.
1185 QUrl QWebHitTestResult::linkTitle() const
1189 return d->linkTitle;
1193 Returns the frame that will load the link if it is activated.
1195 QWebFrame *QWebHitTestResult::linkTargetFrame() const
1199 return d->linkTargetFrame;
1203 Returns the alternate text of the element. This corresponds to the HTML alt attribute.
1205 QString QWebHitTestResult::alternateText() const
1209 return d->alternateText;
1213 Returns the url of the image.
1215 QUrl QWebHitTestResult::imageUrl() const
1223 Returns a QPixmap containing the image. A null pixmap is returned if the
1224 element being tested is not an image.
1226 QPixmap QWebHitTestResult::pixmap() const
1234 Returns true if the content is editable by the user; otherwise returns false.
1236 bool QWebHitTestResult::isContentEditable() const
1240 return d->isContentEditable;
1244 Returns true if the content tested is part of the selection; otherwise returns false.
1246 bool QWebHitTestResult::isContentSelected() const
1250 return d->isContentSelected;
1254 Returns the frame the hit test was executed in.
1256 QWebFrame *QWebHitTestResult::frame() const