/* 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 "qwebsecurityorigin.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; } 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{