File indexing completed on 2024-04-21 14:58:49

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
0004  *                     1999-2001 Lars Knoll <knoll@kde.org>
0005  *                     1999-2001 Antti Koivisto <koivisto@kde.org>
0006  *                     2000-2001 Simon Hausmann <hausmann@kde.org>
0007  *                     2000-2001 Dirk Mueller <mueller@kde.org>
0008  *                     2000 Stefan Schimanski <1Stein@gmx.de>
0009  *                     2001-2005 George Staikos <staikos@kde.org>
0010  *                     2010 Maksim Orlovich <maksim@kde.org>
0011  *
0012  * This library is free software; you can redistribute it and/or
0013  * modify it under the terms of the GNU Library General Public
0014  * License as published by the Free Software Foundation; either
0015  * version 2 of the License, or (at your option) any later version.
0016  *
0017  * This library is distributed in the hope that it will be useful,
0018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0020  * Library General Public License for more details.
0021  *
0022  * You should have received a copy of the GNU Library General Public License
0023  * along with this library; see the file COPYING.LIB.  If not, write to
0024  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0025  * Boston, MA 02110-1301, USA.
0026  */
0027 #include "khtml_childframe_p.h"
0028 #include "khtmlpart_p.h"
0029 #include "khtml_part.h"
0030 
0031 namespace khtml
0032 {
0033 
0034 ChildFrame::ChildFrame() : QObject(nullptr)
0035 {
0036     setObjectName("khtml_child_frame");
0037     m_jscript = nullptr;
0038     m_bCompleted = false; m_bPreloaded = false; m_type = Frame; m_bNotify = false;
0039     m_bPendingRedirection = false;
0040 }
0041 
0042 ChildFrame::~ChildFrame()
0043 {
0044     if (m_run) {
0045         m_run.data()->abort();
0046     }
0047     delete m_jscript;
0048 }
0049 
0050 const char *ChildFrame::typeString() const
0051 {
0052     switch (m_type) {
0053     case khtml::ChildFrame::Frame:
0054         return "frame";
0055     case khtml::ChildFrame::IFrame:
0056         return "iframe";
0057     case khtml::ChildFrame::Object:
0058         return "object";
0059     default:
0060         return "HUH???";
0061     }
0062 }
0063 
0064 static QDebug &ind(const QDebug &dbgIn, int ind)
0065 {
0066     QDebug &dbg = const_cast<QDebug &>(dbgIn);
0067 
0068     for (int i = 0; i < ind; ++i) {
0069         dbg << " ";
0070     }
0071     return dbg;
0072 }
0073 
0074 void ChildFrame::dump(int i)
0075 {
0076     ind(qDebug(), i) << typeString() << m_name
0077                      << this << m_part.data()
0078                      << "url:" << (m_part.isNull() ?
0079                                    QString::fromLatin1("") :
0080                                    m_part->url().toString())
0081                      << "el:" << (m_partContainerElement.isNull() ?
0082                                   QString::fromLatin1("") :
0083                                   DOM::getPrintableName(m_partContainerElement.data()->id()))
0084                      << "sn:" << m_serviceName << "st:" << m_serviceType
0085                      << "kr:" << m_run.data() << "comp:" << m_bCompleted;
0086 }
0087 
0088 void ChildFrame::dumpFrameTree(KHTMLPart *part)
0089 {
0090     static int i = 0;
0091 
0092     KHTMLPartPrivate *d = part->impl();
0093 
0094     if (!d->m_objects.isEmpty()) {
0095         ind(qDebug(), i) << "objects:";
0096         i += 4;
0097 
0098         for (QList<khtml::ChildFrame *>::Iterator io = d->m_objects.begin(); io != d->m_objects.end(); ++io) {
0099             khtml::ChildFrame *cf = (*io);
0100             cf->dump(i);
0101             if (KHTMLPart *p = ::qobject_cast<KHTMLPart *>(cf->m_part.data())) {
0102                 i += 4;
0103                 dumpFrameTree(p);
0104                 i -= 4;
0105             }
0106         }
0107         i -= 4;
0108     }
0109 
0110     if (!d->m_frames.isEmpty()) {
0111         ind(qDebug(), i) << "frames:";
0112         i += 4;
0113 
0114         for (QList<khtml::ChildFrame *>::Iterator ifr = d->m_frames.begin(); ifr != d->m_frames.end(); ++ifr) {
0115             khtml::ChildFrame *cf = (*ifr);
0116             cf->dump(i);
0117             if (KHTMLPart *p = ::qobject_cast<KHTMLPart *>(cf->m_part.data())) {
0118                 i += 4;
0119                 dumpFrameTree(p);
0120                 i -= 4;
0121             }
0122         }
0123         i -= 4;
0124     }
0125 }
0126 
0127 } // namespace khtml
0128 
0129 KHTMLFrameList::Iterator KHTMLFrameList::find(const QString &name)
0130 {
0131     Iterator it = begin();
0132     const Iterator e = end();
0133 
0134     for (; it != e; ++it)
0135         if ((*it)->m_name == name) {
0136             break;
0137         }
0138 
0139     return it;
0140 }
0141 
0142 #include "moc_khtml_childframe_p.cpp"