KHtml

khtml_childframe.cpp
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 1998, 1999 Torben Weis <[email protected]>
4  * 1999-2001 Lars Knoll <[email protected]>
5  * 1999-2001 Antti Koivisto <[email protected]>
6  * 2000-2001 Simon Hausmann <[email protected]>
7  * 2000-2001 Dirk Mueller <[email protected]>
8  * 2000 Stefan Schimanski <[email protected]>
9  * 2001-2005 George Staikos <[email protected]>
10  * 2010 Maksim Orlovich <[email protected]>
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public License
23  * along with this library; see the file COPYING.LIB. If not, write to
24  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25  * Boston, MA 02110-1301, USA.
26  */
27 #include "khtml_childframe_p.h"
28 #include "khtmlpart_p.h"
29 #include "khtml_part.h"
30 
31 namespace khtml
32 {
33 
34 ChildFrame::ChildFrame() : QObject(nullptr)
35 {
36  setObjectName("khtml_child_frame");
37  m_jscript = nullptr;
38  m_bCompleted = false; m_bPreloaded = false; m_type = Frame; m_bNotify = false;
39  m_bPendingRedirection = false;
40 }
41 
42 ChildFrame::~ChildFrame()
43 {
44  if (m_run) {
45  m_run.data()->abort();
46  }
47  delete m_jscript;
48 }
49 
50 const char *ChildFrame::typeString() const
51 {
52  switch (m_type) {
53  case khtml::ChildFrame::Frame:
54  return "frame";
55  case khtml::ChildFrame::IFrame:
56  return "iframe";
57  case khtml::ChildFrame::Object:
58  return "object";
59  default:
60  return "HUH???";
61  }
62 }
63 
64 static QDebug &ind(const QDebug &dbgIn, int ind)
65 {
66  QDebug &dbg = const_cast<QDebug &>(dbgIn);
67 
68  for (int i = 0; i < ind; ++i) {
69  dbg << " ";
70  }
71  return dbg;
72 }
73 
74 void ChildFrame::dump(int i)
75 {
76  ind(qDebug(), i) << typeString() << m_name
77  << this << m_part.data()
78  << "url:" << (m_part.isNull() ?
80  m_part->url().toString())
81  << "el:" << (m_partContainerElement.isNull() ?
82  QString::fromLatin1("") :
83  DOM::getPrintableName(m_partContainerElement.data()->id()))
84  << "sn:" << m_serviceName << "st:" << m_serviceType
85  << "kr:" << m_run.data() << "comp:" << m_bCompleted;
86 }
87 
88 void ChildFrame::dumpFrameTree(KHTMLPart *part)
89 {
90  static int i = 0;
91 
92  KHTMLPartPrivate *d = part->impl();
93 
94  if (!d->m_objects.isEmpty()) {
95  ind(qDebug(), i) << "objects:";
96  i += 4;
97 
98  for (QList<khtml::ChildFrame *>::Iterator io = d->m_objects.begin(); io != d->m_objects.end(); ++io) {
99  khtml::ChildFrame *cf = (*io);
100  cf->dump(i);
101  if (KHTMLPart *p = ::qobject_cast<KHTMLPart *>(cf->m_part.data())) {
102  i += 4;
103  dumpFrameTree(p);
104  i -= 4;
105  }
106  }
107  i -= 4;
108  }
109 
110  if (!d->m_frames.isEmpty()) {
111  ind(qDebug(), i) << "frames:";
112  i += 4;
113 
114  for (QList<khtml::ChildFrame *>::Iterator ifr = d->m_frames.begin(); ifr != d->m_frames.end(); ++ifr) {
115  khtml::ChildFrame *cf = (*ifr);
116  cf->dump(i);
117  if (KHTMLPart *p = ::qobject_cast<KHTMLPart *>(cf->m_part.data())) {
118  i += 4;
119  dumpFrameTree(p);
120  i -= 4;
121  }
122  }
123  i -= 4;
124  }
125 }
126 
127 } // namespace khtml
128 
129 KHTMLFrameList::Iterator KHTMLFrameList::find(const QString &name)
130 {
131  Iterator it = begin();
132  const Iterator e = end();
133 
134  for (; it != e; ++it)
135  if ((*it)->m_name == name) {
136  break;
137  }
138 
139  return it;
140 }
141 
This file is part of the HTML rendering engine for KDE.
This class is khtml&#39;s main class.
Definition: khtml_part.h:208
const QList< QKeySequence > & begin()
This library provides a full-featured HTML parser and widget.
const QList< QKeySequence > & end()
char * toString(const T &value)
QString fromLatin1(const char *str, int size)
KHTMLPartPrivate * impl()
Definition: khtml_part.h:1934
QList::iterator begin()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.