OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 | 42 |
43 FrameTree::FrameTree(Frame* thisFrame) | 43 FrameTree::FrameTree(Frame* thisFrame) |
44 : m_thisFrame(thisFrame) | 44 : m_thisFrame(thisFrame) |
45 , m_scopedChildCount(invalidChildCount) | 45 , m_scopedChildCount(invalidChildCount) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 FrameTree::~FrameTree() | 49 FrameTree::~FrameTree() |
50 { | 50 { |
51 // FIXME: Why is this here? Doesn't this parallel what we already do in ~Loc alFrame? | 51 // FIXME: Why is this here? Doesn't this parallel what we already do in ~Loc alFrame? |
52 for (LocalFrame* child = firstChild(); child; child = child->tree().nextSibl ing()) | 52 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { |
53 child->setView(nullptr); | 53 if (child->isLocalFrame()) |
54 toLocalFrame(child)->setView(nullptr); | |
dcheng
2014/06/09 21:12:32
Do we need to clear the view for RemoteFrames as w
kenrb
2014/06/10 16:55:29
I hadn't really thought about RemoteFrameView life
| |
55 } | |
54 } | 56 } |
55 | 57 |
56 void FrameTree::setName(const AtomicString& name, const AtomicString& fallbackNa me) | 58 void FrameTree::setName(const AtomicString& name, const AtomicString& fallbackNa me) |
57 { | 59 { |
58 m_name = name; | 60 m_name = name; |
59 if (!parent()) { | 61 if (!parent()) { |
60 m_uniqueName = name; | 62 m_uniqueName = name; |
61 return; | 63 return; |
62 } | 64 } |
63 m_uniqueName = AtomicString(); // Remove our old frame name so it's not cons idered in uniqueChildName. | 65 m_uniqueName = AtomicString(); // Remove our old frame name so it's not cons idered in uniqueChildName. |
64 m_uniqueName = parent()->tree().uniqueChildName(name.isEmpty() ? fallbackNam e : name); | 66 m_uniqueName = parent()->tree().uniqueChildName(name.isEmpty() ? fallbackNam e : name); |
65 } | 67 } |
66 | 68 |
67 LocalFrame* FrameTree::parent() const | 69 Frame* FrameTree::parent() const |
68 { | 70 { |
69 if (!m_thisFrame->client()) | 71 if (!m_thisFrame->client()) |
70 return 0; | 72 return 0; |
71 // FIXME: Temporary hack to stage converting locations that really should be Frame. | 73 return m_thisFrame->client()->parent(); |
72 return toLocalFrame(m_thisFrame->client()->parent()); | |
73 } | 74 } |
74 | 75 |
75 LocalFrame* FrameTree::top() const | 76 Frame* FrameTree::top() const |
76 { | 77 { |
77 // FIXME: top() should never return null, so here are some hacks to deal | 78 // FIXME: top() should never return null, so here are some hacks to deal |
78 // with EmptyFrameLoaderClient and cases where the frame is detached | 79 // with EmptyFrameLoaderClient and cases where the frame is detached |
79 // already... | 80 // already... |
80 if (!m_thisFrame->client()) | 81 if (!m_thisFrame->client()) |
81 return toLocalFrame(m_thisFrame); | 82 return m_thisFrame; |
82 // FIXME: Temporary hack to stage converting locations that really should be Frame. | 83 Frame* candidate = m_thisFrame->client()->top(); |
83 LocalFrame* candidate = toLocalFrame(m_thisFrame->client()->top()); | 84 return candidate ? candidate : m_thisFrame; |
84 return candidate ? candidate : toLocalFrame(m_thisFrame); | |
85 } | 85 } |
86 | 86 |
87 LocalFrame* FrameTree::previousSibling() const | 87 Frame* FrameTree::previousSibling() const |
88 { | 88 { |
89 if (!m_thisFrame->client()) | 89 if (!m_thisFrame->client()) |
90 return 0; | 90 return 0; |
91 // FIXME: Temporary hack to stage converting locations that really should be Frame. | 91 return m_thisFrame->client()->previousSibling(); |
92 return toLocalFrame(m_thisFrame->client()->previousSibling()); | |
93 } | 92 } |
94 | 93 |
95 LocalFrame* FrameTree::nextSibling() const | 94 Frame* FrameTree::nextSibling() const |
96 { | 95 { |
97 if (!m_thisFrame->client()) | 96 if (!m_thisFrame->client()) |
98 return 0; | 97 return 0; |
99 // FIXME: Temporary hack to stage converting locations that really should be Frame. | 98 return m_thisFrame->client()->nextSibling(); |
100 return toLocalFrame(m_thisFrame->client()->nextSibling()); | |
101 } | 99 } |
102 | 100 |
103 LocalFrame* FrameTree::firstChild() const | 101 Frame* FrameTree::firstChild() const |
104 { | 102 { |
105 if (!m_thisFrame->client()) | 103 if (!m_thisFrame->client()) |
106 return 0; | 104 return 0; |
107 // FIXME: Temporary hack to stage converting locations that really should be Frame. | 105 return m_thisFrame->client()->firstChild(); |
108 return toLocalFrame(m_thisFrame->client()->firstChild()); | |
109 } | 106 } |
110 | 107 |
111 LocalFrame* FrameTree::lastChild() const | 108 Frame* FrameTree::lastChild() const |
112 { | 109 { |
113 if (!m_thisFrame->client()) | 110 if (!m_thisFrame->client()) |
114 return 0; | 111 return 0; |
115 // FIXME: Temporary hack to stage converting locations that really should be Frame. | 112 return m_thisFrame->client()->lastChild(); |
116 return toLocalFrame(m_thisFrame->client()->lastChild()); | |
117 } | 113 } |
118 | 114 |
119 bool FrameTree::uniqueNameExists(const AtomicString& name) const | 115 bool FrameTree::uniqueNameExists(const AtomicString& name) const |
120 { | 116 { |
121 for (LocalFrame* frame = top(); frame; frame = frame->tree().traverseNext()) { | 117 for (Frame* frame = top(); frame; frame = frame->tree().traverseNext()) { |
122 if (frame->tree().uniqueName() == name) | 118 if (frame->tree().uniqueName() == name) |
123 return true; | 119 return true; |
124 } | 120 } |
125 return false; | 121 return false; |
126 } | 122 } |
127 | 123 |
128 AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const | 124 AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const |
129 { | 125 { |
130 if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requeste dName != "_blank") | 126 if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requeste dName != "_blank") |
131 return requestedName; | 127 return requestedName; |
132 | 128 |
133 // Create a repeatable name for a child about to be added to us. The name mu st be | 129 // Create a repeatable name for a child about to be added to us. The name mu st be |
134 // unique within the frame tree. The string we generate includes a "path" of names | 130 // unique within the frame tree. The string we generate includes a "path" of names |
135 // from the root frame down to us. For this path to be unique, each set of s iblings must | 131 // from the root frame down to us. For this path to be unique, each set of s iblings must |
136 // contribute a unique name to the path, which can't collide with any HTML-a ssigned names. | 132 // contribute a unique name to the path, which can't collide with any HTML-a ssigned names. |
137 // We generate this path component by index in the child list along with an unlikely | 133 // We generate this path component by index in the child list along with an unlikely |
138 // frame name that can't be set in HTML because it collides with comment syn tax. | 134 // frame name that can't be set in HTML because it collides with comment syn tax. |
139 | 135 |
140 const char framePathPrefix[] = "<!--framePath "; | 136 const char framePathPrefix[] = "<!--framePath "; |
141 const int framePathPrefixLength = 14; | 137 const int framePathPrefixLength = 14; |
142 const int framePathSuffixLength = 3; | 138 const int framePathSuffixLength = 3; |
143 | 139 |
144 // Find the nearest parent that has a frame with a path in it. | 140 // Find the nearest parent that has a frame with a path in it. |
145 Vector<LocalFrame*, 16> chain; | 141 Vector<Frame*, 16> chain; |
146 LocalFrame* frame; | 142 Frame* frame; |
147 for (frame = toLocalFrame(m_thisFrame); frame; frame = frame->tree().parent( )) { | 143 for (frame = m_thisFrame; frame; frame = frame->tree().parent()) { |
148 if (frame->tree().uniqueName().startsWith(framePathPrefix)) | 144 if (frame->tree().uniqueName().startsWith(framePathPrefix)) |
149 break; | 145 break; |
150 chain.append(frame); | 146 chain.append(frame); |
151 } | 147 } |
152 StringBuilder name; | 148 StringBuilder name; |
153 name.append(framePathPrefix); | 149 name.append(framePathPrefix); |
154 if (frame) { | 150 if (frame) { |
155 name.append(frame->tree().uniqueName().string().substring(framePathPrefi xLength, | 151 name.append(frame->tree().uniqueName().string().substring(framePathPrefi xLength, |
156 frame->tree().uniqueName().length() - framePathPrefixLength - frameP athSuffixLength)); | 152 frame->tree().uniqueName().length() - framePathPrefixLength - frameP athSuffixLength)); |
157 } | 153 } |
158 for (int i = chain.size() - 1; i >= 0; --i) { | 154 for (int i = chain.size() - 1; i >= 0; --i) { |
159 frame = chain[i]; | 155 frame = chain[i]; |
160 name.append('/'); | 156 name.append('/'); |
161 name.append(frame->tree().uniqueName()); | 157 name.append(frame->tree().uniqueName()); |
162 } | 158 } |
163 | 159 |
164 name.appendLiteral("/<!--frame"); | 160 name.appendLiteral("/<!--frame"); |
165 name.appendNumber(childCount() - 1); | 161 name.appendNumber(childCount() - 1); |
166 name.appendLiteral("-->-->"); | 162 name.appendLiteral("-->-->"); |
167 | 163 |
168 return name.toAtomicString(); | 164 return name.toAtomicString(); |
169 } | 165 } |
170 | 166 |
171 LocalFrame* FrameTree::scopedChild(unsigned index) const | 167 Frame* FrameTree::scopedChild(unsigned index) const |
172 { | 168 { |
169 if (!m_thisFrame->isLocalFrame()) | |
170 return 0; | |
173 TreeScope* scope = toLocalFrame(m_thisFrame)->document(); | 171 TreeScope* scope = toLocalFrame(m_thisFrame)->document(); |
174 if (!scope) | 172 if (!scope) |
175 return 0; | 173 return 0; |
176 | 174 |
177 unsigned scopedIndex = 0; | 175 unsigned scopedIndex = 0; |
178 for (LocalFrame* result = firstChild(); result; result = result->tree().next Sibling()) { | 176 for (Frame* result = firstChild(); result; result = result->tree().nextSibli ng()) { |
179 if (result->inScope(scope)) { | 177 if (result->isLocalFrame() && toLocalFrame(result)->inScope(scope)) { |
180 if (scopedIndex == index) | 178 if (scopedIndex == index) |
181 return result; | 179 return result; |
182 scopedIndex++; | 180 scopedIndex++; |
183 } | 181 } |
184 } | 182 } |
185 | 183 |
186 return 0; | 184 return 0; |
187 } | 185 } |
188 | 186 |
189 LocalFrame* FrameTree::scopedChild(const AtomicString& name) const | 187 Frame* FrameTree::scopedChild(const AtomicString& name) const |
190 { | 188 { |
189 if (!m_thisFrame->isLocalFrame()) | |
190 return 0; | |
191 | |
191 TreeScope* scope = toLocalFrame(m_thisFrame)->document(); | 192 TreeScope* scope = toLocalFrame(m_thisFrame)->document(); |
192 if (!scope) | 193 if (!scope) |
193 return 0; | 194 return 0; |
194 | 195 |
195 for (LocalFrame* child = firstChild(); child; child = child->tree().nextSibl ing()) | 196 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) |
196 if (child->tree().name() == name && child->inScope(scope)) | 197 if (child->tree().name() == name && child->isLocalFrame() && toLocalFram e(child)->inScope(scope)) |
197 return child; | 198 return child; |
198 return 0; | 199 return 0; |
199 } | 200 } |
200 | 201 |
201 inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const | 202 inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const |
202 { | 203 { |
203 if (!scope) | 204 if (!scope) |
204 return 0; | 205 return 0; |
205 | 206 |
206 unsigned scopedCount = 0; | 207 unsigned scopedCount = 0; |
207 for (LocalFrame* result = firstChild(); result; result = result->tree().next Sibling()) { | 208 for (Frame* result = firstChild(); result; result = result->tree().nextSibli ng()) { |
208 if (result->inScope(scope)) | 209 if (result->isLocalFrame() && toLocalFrame(result)->inScope(scope)) |
209 scopedCount++; | 210 scopedCount++; |
210 } | 211 } |
211 | 212 |
212 return scopedCount; | 213 return scopedCount; |
213 } | 214 } |
214 | 215 |
215 unsigned FrameTree::scopedChildCount() const | 216 unsigned FrameTree::scopedChildCount() const |
216 { | 217 { |
217 if (m_scopedChildCount == invalidChildCount) | 218 if (m_scopedChildCount == invalidChildCount) |
218 m_scopedChildCount = scopedChildCount(toLocalFrame(m_thisFrame)->documen t()); | 219 m_scopedChildCount = scopedChildCount(toLocalFrame(m_thisFrame)->documen t()); |
219 return m_scopedChildCount; | 220 return m_scopedChildCount; |
220 } | 221 } |
221 | 222 |
222 void FrameTree::invalidateScopedChildCount() | 223 void FrameTree::invalidateScopedChildCount() |
223 { | 224 { |
224 m_scopedChildCount = invalidChildCount; | 225 m_scopedChildCount = invalidChildCount; |
225 } | 226 } |
226 | 227 |
227 unsigned FrameTree::childCount() const | 228 unsigned FrameTree::childCount() const |
228 { | 229 { |
229 unsigned count = 0; | 230 unsigned count = 0; |
230 for (LocalFrame* result = firstChild(); result; result = result->tree().next Sibling()) | 231 for (Frame* result = firstChild(); result; result = result->tree().nextSibli ng()) |
231 ++count; | 232 ++count; |
232 return count; | 233 return count; |
233 } | 234 } |
234 | 235 |
235 LocalFrame* FrameTree::child(const AtomicString& name) const | 236 Frame* FrameTree::child(const AtomicString& name) const |
236 { | 237 { |
237 for (LocalFrame* child = firstChild(); child; child = child->tree().nextSibl ing()) | 238 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) |
238 if (child->tree().name() == name) | 239 if (child->tree().name() == name) |
239 return child; | 240 return child; |
240 return 0; | 241 return 0; |
241 } | 242 } |
242 | 243 |
243 LocalFrame* FrameTree::find(const AtomicString& name) const | 244 Frame* FrameTree::find(const AtomicString& name) const |
244 { | 245 { |
245 if (name == "_self" || name == "_current" || name.isEmpty()) | 246 if (name == "_self" || name == "_current" || name.isEmpty()) |
246 return toLocalFrame(m_thisFrame); | 247 return m_thisFrame; |
247 | 248 |
248 if (name == "_top") | 249 if (name == "_top") |
249 return top(); | 250 return top(); |
250 | 251 |
251 if (name == "_parent") | 252 if (name == "_parent") |
252 return parent() ? parent() : toLocalFrame(m_thisFrame); | 253 return parent() ? parent() : m_thisFrame; |
253 | 254 |
254 // Since "_blank" should never be any frame's name, the following just amoun ts to an optimization. | 255 // Since "_blank" should never be any frame's name, the following just amoun ts to an optimization. |
255 if (name == "_blank") | 256 if (name == "_blank") |
256 return 0; | 257 return 0; |
257 | 258 |
258 // Search subtree starting with this frame first. | 259 // Search subtree starting with this frame first. |
259 for (LocalFrame* frame = toLocalFrame(m_thisFrame); frame; frame = frame->tr ee().traverseNext(toLocalFrame(m_thisFrame))) | 260 for (Frame* frame = m_thisFrame; frame; frame = frame->tree().traverseNext(m _thisFrame)) |
260 if (frame->tree().name() == name) | 261 if (frame->tree().name() == name) |
261 return frame; | 262 return frame; |
262 | 263 |
263 // Search the entire tree for this page next. | 264 // Search the entire tree for this page next. |
264 Page* page = m_thisFrame->page(); | 265 Page* page = m_thisFrame->page(); |
265 | 266 |
266 // The frame could have been detached from the page, so check it. | 267 // The frame could have been detached from the page, so check it. |
267 if (!page) | 268 if (!page) |
268 return 0; | 269 return 0; |
269 | 270 |
270 for (LocalFrame* frame = page->mainFrame(); frame; frame = frame->tree().tra verseNext()) | 271 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse Next()) |
271 if (frame->tree().name() == name) | 272 if (frame->tree().name() == name) |
272 return frame; | 273 return frame; |
273 | 274 |
274 // Search the entire tree of each of the other pages in this namespace. | 275 // Search the entire tree of each of the other pages in this namespace. |
275 // FIXME: Is random order OK? | 276 // FIXME: Is random order OK? |
276 const HashSet<Page*>& pages = Page::ordinaryPages(); | 277 const HashSet<Page*>& pages = Page::ordinaryPages(); |
277 HashSet<Page*>::const_iterator end = pages.end(); | 278 HashSet<Page*>::const_iterator end = pages.end(); |
278 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { | 279 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { |
279 Page* otherPage = *it; | 280 Page* otherPage = *it; |
280 if (otherPage != page) { | 281 if (otherPage != page) { |
281 for (LocalFrame* frame = otherPage->mainFrame(); frame; frame = fram e->tree().traverseNext()) { | 282 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tr ee().traverseNext()) { |
282 if (frame->tree().name() == name) | 283 if (frame->tree().name() == name) |
283 return frame; | 284 return frame; |
284 } | 285 } |
285 } | 286 } |
286 } | 287 } |
287 | 288 |
288 return 0; | 289 return 0; |
289 } | 290 } |
290 | 291 |
291 bool FrameTree::isDescendantOf(const LocalFrame* ancestor) const | 292 bool FrameTree::isDescendantOf(const Frame* ancestor) const |
292 { | 293 { |
293 if (!ancestor) | 294 if (!ancestor) |
294 return false; | 295 return false; |
295 | 296 |
296 if (m_thisFrame->page() != ancestor->page()) | 297 if (m_thisFrame->page() != ancestor->page()) |
297 return false; | 298 return false; |
298 | 299 |
299 for (LocalFrame* frame = toLocalFrame(m_thisFrame); frame; frame = frame->tr ee().parent()) | 300 for (Frame* frame = m_thisFrame; frame; frame = frame->tree().parent()) |
300 if (frame == ancestor) | 301 if (frame == ancestor) |
301 return true; | 302 return true; |
302 return false; | 303 return false; |
303 } | 304 } |
304 | 305 |
305 LocalFrame* FrameTree::traverseNext(const LocalFrame* stayWithin) const | 306 Frame* FrameTree::traverseNext(const Frame* stayWithin) const |
306 { | 307 { |
307 LocalFrame* child = firstChild(); | 308 Frame* child = firstChild(); |
308 if (child) { | 309 if (child) { |
309 ASSERT(!stayWithin || child->tree().isDescendantOf(stayWithin)); | 310 ASSERT(!stayWithin || child->tree().isDescendantOf(stayWithin)); |
310 return child; | 311 return child; |
311 } | 312 } |
312 | 313 |
313 if (m_thisFrame == stayWithin) | 314 if (m_thisFrame == stayWithin) |
314 return 0; | 315 return 0; |
315 | 316 |
316 LocalFrame* sibling = nextSibling(); | 317 Frame* sibling = nextSibling(); |
317 if (sibling) { | 318 if (sibling) { |
318 ASSERT(!stayWithin || sibling->tree().isDescendantOf(stayWithin)); | 319 ASSERT(!stayWithin || sibling->tree().isDescendantOf(stayWithin)); |
319 return sibling; | 320 return sibling; |
320 } | 321 } |
321 | 322 |
322 LocalFrame* frame = toLocalFrame(m_thisFrame); | 323 Frame* frame = m_thisFrame; |
323 while (!sibling && (!stayWithin || frame->tree().parent() != stayWithin)) { | 324 while (!sibling && (!stayWithin || frame->tree().parent() != stayWithin)) { |
324 frame = frame->tree().parent(); | 325 frame = frame->tree().parent(); |
325 if (!frame) | 326 if (!frame) |
326 return 0; | 327 return 0; |
327 sibling = frame->tree().nextSibling(); | 328 sibling = frame->tree().nextSibling(); |
328 } | 329 } |
329 | 330 |
330 if (frame) { | 331 if (frame) { |
331 ASSERT(!stayWithin || !sibling || sibling->tree().isDescendantOf(stayWit hin)); | 332 ASSERT(!stayWithin || !sibling || sibling->tree().isDescendantOf(stayWit hin)); |
332 return sibling; | 333 return sibling; |
333 } | 334 } |
334 | 335 |
335 return 0; | 336 return 0; |
336 } | 337 } |
337 | 338 |
338 LocalFrame* FrameTree::traverseNextWithWrap(bool wrap) const | 339 Frame* FrameTree::traverseNextWithWrap(bool wrap) const |
339 { | 340 { |
340 if (LocalFrame* result = traverseNext()) | 341 if (Frame* result = traverseNext()) |
341 return result; | 342 return result; |
342 | 343 |
343 if (wrap) | 344 if (wrap) |
344 return m_thisFrame->page()->mainFrame(); | 345 return m_thisFrame->page()->mainFrame(); |
345 | 346 |
346 return 0; | 347 return 0; |
347 } | 348 } |
348 | 349 |
349 LocalFrame* FrameTree::traversePreviousWithWrap(bool wrap) const | 350 Frame* FrameTree::traversePreviousWithWrap(bool wrap) const |
350 { | 351 { |
351 // FIXME: besides the wrap feature, this is just the traversePreviousNode al gorithm | 352 // FIXME: besides the wrap feature, this is just the traversePreviousNode al gorithm |
352 | 353 |
353 if (LocalFrame* prevSibling = previousSibling()) | 354 if (Frame* prevSibling = previousSibling()) |
354 return prevSibling->tree().deepLastChild(); | 355 return prevSibling->tree().deepLastChild(); |
355 if (LocalFrame* parentFrame = parent()) | 356 if (Frame* parentFrame = parent()) |
356 return parentFrame; | 357 return parentFrame; |
357 | 358 |
358 // no siblings, no parent, self==top | 359 // no siblings, no parent, self==top |
359 if (wrap) | 360 if (wrap) |
360 return deepLastChild(); | 361 return deepLastChild(); |
361 | 362 |
362 // top view is always the last one in this ordering, so prev is nil without wrap | 363 // top view is always the last one in this ordering, so prev is nil without wrap |
363 return 0; | 364 return 0; |
364 } | 365 } |
365 | 366 |
366 LocalFrame* FrameTree::deepLastChild() const | 367 Frame* FrameTree::deepLastChild() const |
367 { | 368 { |
368 LocalFrame* result = toLocalFrame(m_thisFrame); | 369 Frame* result = m_thisFrame; |
369 for (LocalFrame* last = lastChild(); last; last = last->tree().lastChild()) | 370 for (Frame* last = lastChild(); last; last = last->tree().lastChild()) |
370 result = last; | 371 result = last; |
371 | 372 |
372 return result; | 373 return result; |
373 } | 374 } |
374 | 375 |
375 } // namespace WebCore | 376 } // namespace WebCore |
376 | 377 |
377 #ifndef NDEBUG | 378 #ifndef NDEBUG |
378 | 379 |
379 static void printIndent(int indent) | 380 static void printIndent(int indent) |
380 { | 381 { |
381 for (int i = 0; i < indent; ++i) | 382 for (int i = 0; i < indent; ++i) |
382 printf(" "); | 383 printf(" "); |
383 } | 384 } |
384 | 385 |
385 static void printFrames(const WebCore::LocalFrame* frame, const WebCore::LocalFr ame* targetFrame, int indent) | 386 static void printFrames(const WebCore::Frame* frame, const WebCore::Frame* targe tFrame, int indent) |
386 { | 387 { |
387 if (frame == targetFrame) { | 388 if (frame == targetFrame) { |
388 printf("--> "); | 389 printf("--> "); |
389 printIndent(indent - 1); | 390 printIndent(indent - 1); |
390 } else | 391 } else |
391 printIndent(indent); | 392 printIndent(indent); |
392 | 393 |
393 WebCore::FrameView* view = frame->view(); | 394 WebCore::FrameView* view = frame->isLocalFrame() ? toLocalFrame(frame)->view () : 0; |
394 printf("LocalFrame %p %dx%d\n", frame, view ? view->width() : 0, view ? view ->height() : 0); | 395 printf("Frame %p %dx%d\n", frame, view ? view->width() : 0, view ? view->hei ght() : 0); |
395 printIndent(indent); | 396 printIndent(indent); |
396 printf(" owner=%p\n", frame->owner()); | 397 printf(" owner=%p\n", frame->owner()); |
397 printIndent(indent); | 398 printIndent(indent); |
398 printf(" frameView=%p\n", view); | 399 printf(" frameView=%p\n", view); |
399 printIndent(indent); | 400 printIndent(indent); |
400 printf(" document=%p\n", frame->document()); | 401 printf(" document=%p\n", frame->isLocalFrame() ? toLocalFrame(frame)->docum ent() : 0); |
401 printIndent(indent); | 402 printIndent(indent); |
402 printf(" uri=%s\n\n", frame->document()->url().string().utf8().data()); | 403 printf(" uri=%s\n\n", frame->isLocalFrame() ? toLocalFrame(frame)->document ()->url().string().utf8().data() : 0); |
403 | 404 |
404 for (WebCore::LocalFrame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling()) | 405 for (WebCore::Frame* child = frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) |
405 printFrames(child, targetFrame, indent + 1); | 406 printFrames(child, targetFrame, indent + 1); |
406 } | 407 } |
407 | 408 |
408 void showFrameTree(const WebCore::LocalFrame* frame) | 409 void showFrameTree(const WebCore::Frame* frame) |
409 { | 410 { |
410 if (!frame) { | 411 if (!frame) { |
411 printf("Null input frame\n"); | 412 printf("Null input frame\n"); |
412 return; | 413 return; |
413 } | 414 } |
414 | 415 |
415 printFrames(frame->tree().top(), frame, 0); | 416 printFrames(frame->tree().top(), frame, 0); |
416 } | 417 } |
417 | 418 |
418 #endif | 419 #endif |
OLD | NEW |