1 | /* This file is part of the KDE project |
2 | * |
3 | * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
4 | * 1999-2001 Lars Knoll <knoll@kde.org> |
5 | * 1999-2001 Antti Koivisto <koivisto@kde.org> |
6 | * 2000-2001 Simon Hausmann <hausmann@kde.org> |
7 | * 2000-2001 Dirk Mueller <mueller@kde.org> |
8 | * 2000 Stefan Schimanski <1Stein@gmx.de> |
9 | * 2001-2005 George Staikos <staikos@kde.org> |
10 | * 2010 Maksim Orlovich <maksim@kde.org> |
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 | ChildFrame::ChildFrame() : QObject (0) { |
34 | setObjectName( "khtml_child_frame" ); |
35 | m_jscript = 0L; |
36 | m_bCompleted = false; m_bPreloaded = false; m_type = Frame; m_bNotify = false; |
37 | m_bPendingRedirection = false; |
38 | } |
39 | |
40 | ChildFrame::~ChildFrame() { |
41 | if (m_run) |
42 | m_run.data()->abort(); |
43 | delete m_jscript; |
44 | } |
45 | |
46 | const char* ChildFrame::typeString() const |
47 | { |
48 | switch (m_type) { |
49 | case khtml::ChildFrame::Frame: |
50 | return "frame" ; |
51 | case khtml::ChildFrame::IFrame: |
52 | return "iframe" ; |
53 | case khtml::ChildFrame::Object: |
54 | return "object" ; |
55 | default: |
56 | return "HUH???" ; |
57 | } |
58 | } |
59 | |
60 | static QDebug& ind(const QDebug& dbgIn, int ind) |
61 | { |
62 | QDebug& dbg = const_cast<QDebug&>(dbgIn); |
63 | |
64 | for (int i = 0; i < ind; ++i) |
65 | dbg << " " ; |
66 | return dbg; |
67 | } |
68 | |
69 | void ChildFrame::dump(int i) |
70 | { |
71 | ind(qDebug(), i) << typeString() << m_name |
72 | << this << m_part.data() |
73 | << "url:" << (m_part.isNull() ? |
74 | QString::fromLatin1("" ) : |
75 | m_part->url().url()) |
76 | << "el:" << (m_partContainerElement.isNull() ? |
77 | QString::fromLatin1("" ) : |
78 | DOM::getPrintableName(m_partContainerElement.data()->id())) |
79 | << "sn:" << m_serviceName << "st:" << m_serviceType |
80 | << "kr:" << m_run.data() << "comp:" << m_bCompleted; |
81 | } |
82 | |
83 | void ChildFrame::dumpFrameTree(KHTMLPart* part) |
84 | { |
85 | static int i = 0; |
86 | |
87 | KHTMLPartPrivate* d = part->impl(); |
88 | |
89 | if (!d->m_objects.isEmpty()) { |
90 | ind(qDebug(), i) << "objects:" ; |
91 | i += 4; |
92 | |
93 | for (QList<khtml::ChildFrame*>::Iterator io = d->m_objects.begin(); io != d->m_objects.end(); ++io) { |
94 | khtml::ChildFrame* cf = (*io); |
95 | cf->dump(i); |
96 | if (KHTMLPart* p = ::qobject_cast<KHTMLPart*>(cf->m_part.data())) { |
97 | i += 4; |
98 | dumpFrameTree(p); |
99 | i -= 4; |
100 | } |
101 | } |
102 | i -= 4; |
103 | } |
104 | |
105 | if (!d->m_frames.isEmpty()) { |
106 | ind(qDebug(), i) << "frames:" ; |
107 | i += 4; |
108 | |
109 | for (QList<khtml::ChildFrame*>::Iterator ifr = d->m_frames.begin(); ifr != d->m_frames.end(); ++ifr) { |
110 | khtml::ChildFrame* cf = (*ifr); |
111 | cf->dump(i); |
112 | if (KHTMLPart* p = ::qobject_cast<KHTMLPart*>(cf->m_part.data())) { |
113 | i += 4; |
114 | dumpFrameTree(p); |
115 | i -= 4; |
116 | } |
117 | } |
118 | i -= 4; |
119 | } |
120 | } |
121 | |
122 | |
123 | } // namespace khtml |
124 | |
125 | |
126 | KHTMLFrameList::Iterator KHTMLFrameList::find( const QString &name ) |
127 | { |
128 | Iterator it = begin(); |
129 | const Iterator e = end(); |
130 | |
131 | for (; it!=e; ++it ) |
132 | if ( (*it)->m_name==name ) |
133 | break; |
134 | |
135 | return it; |
136 | } |
137 | |
138 | // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on; |
139 | |