From 32ea33253afbbdefd2680aa95ab5f57455272ae7 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 30 Nov 2012 16:58:06 +0100 Subject: Imported WebKit commit 6a4a1d32e1d779548c726c4826cba9d69eb87601 (http://svn.webkit.org/repository/webkit/trunk@136242) Final import for the Qt 5.x series that implements the QtWebKit / QtWebKitWidgets split Extra fixes will be cherry-picked. Change-Id: I844f1ebb99c6d6b75db31d6538c2acd628e79681 Reviewed-by: Simon Hausmann --- Source/WebKit/qt/WidgetApi/qwebframe.cpp | 1281 ++++++++++++++++++++++++++++++ 1 file changed, 1281 insertions(+) create mode 100644 Source/WebKit/qt/WidgetApi/qwebframe.cpp (limited to 'Source/WebKit/qt/WidgetApi/qwebframe.cpp') diff --git a/Source/WebKit/qt/WidgetApi/qwebframe.cpp b/Source/WebKit/qt/WidgetApi/qwebframe.cpp new file mode 100644 index 000000000..f07517f93 --- /dev/null +++ b/Source/WebKit/qt/WidgetApi/qwebframe.cpp @@ -0,0 +1,1281 @@ +/* + Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2007 Staikos Computing Services Inc. + + 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 "config.h" +#include "qwebframe.h" + +#include "QtPrintContext.h" +#include "qwebelement.h" +#include "qwebframe_p.h" +#include "qwebpage.h" +#include "qwebpage_p.h" +#include "qwebscriptworld.h" +#include "qwebscriptworld_p.h" +#include "qwebsecurityorigin.h" +#include "qwebsettings.h" +#include +#include +#include +#include +#include +#if HAVE(QTPRINTSUPPORT) +#include +#endif +#include +#include + +using namespace WebCore; + +// from text/qfont.cpp +QT_BEGIN_NAMESPACE +extern Q_GUI_EXPORT int qt_defaultDpi(); +QT_END_NAMESPACE + +void QWebFramePrivate::setPage(QWebPage* newPage) +{ + if (page == newPage) + return; + + // The QWebFrame is created as a child of QWebPage or a parent QWebFrame. + // That adds it to QObject's internal children list and ensures it will be + // deleted when parent QWebPage is deleted. Reparent if needed. + if (q->parent() == qobject_cast(page)) + q->setParent(newPage); + + page = newPage; + pageAdapter = newPage->handle(); + emit q->pageChanged(); +} + +void QWebFramePrivate::emitUrlChanged() +{ + url = coreFrameUrl(); + emit q->urlChanged(url); +} + +void QWebFramePrivate::didStartProvisionalLoad() +{ + emit q->provisionalLoad(); +} + +void QWebFramePrivate::didClearWindowObject() +{ + emit q->javaScriptWindowObjectCleared(); +} + +bool QWebFramePrivate::handleProgressFinished(QPoint *localPos) +{ + QWidget *view = q->page()->view(); + if (!view || !localPos) + return false; + *localPos = view->mapFromGlobal(QCursor::pos()); + return view->hasFocus() && view->rect().contains(*localPos); +} + +void QWebFramePrivate::emitInitialLayoutCompleted() +{ + emit q->initialLayoutCompleted(); +} + +void QWebFramePrivate::emitIconChanged() +{ + emit q->iconChanged(); +} + +void QWebFramePrivate::emitLoadStarted(bool originatingLoad) +{ + if (page && originatingLoad) + emit page->loadStarted(); + emit q->loadStarted(); +} + +void QWebFramePrivate::emitLoadFinished(bool originatingLoad, bool ok) +{ + if (page && originatingLoad) + emit page->loadFinished(ok); + emit q->loadFinished(ok); +} + +QWebFrameAdapter* QWebFramePrivate::createChildFrame(QWebFrameData* frameData) +{ + QWebFrame* newFrame = new QWebFrame(/*parent frame*/q, frameData); + return newFrame->d; +} + +QWebFrame *QWebFramePrivate::apiHandle() +{ + return q; +} + +QObject *QWebFramePrivate::handle() +{ + return q; +} + +void QWebFramePrivate::contentsSizeDidChange(const QSize &size) +{ + emit q->contentsSizeChanged(size); +} + +int QWebFramePrivate::scrollBarPolicy(Qt::Orientation orientation) const +{ + return (int) q->scrollBarPolicy(orientation); +} + +/*! + \class QWebFrame + \since 4.4 + \brief The QWebFrame class represents a frame in a web page. + + \inmodule QtWebKit + + QWebFrame represents a frame inside a web page. Each QWebPage + object contains at least one frame, the main frame, obtained using + QWebPage::mainFrame(). Additional frames will be created for HTML + \c{} or \c{