| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 name.appendLiteral("/<!--frame"); | 166 name.appendLiteral("/<!--frame"); |
| 167 name.appendNumber(childCount() - 1); | 167 name.appendNumber(childCount() - 1); |
| 168 name.appendLiteral("-->-->"); | 168 name.appendLiteral("-->-->"); |
| 169 | 169 |
| 170 return name.toAtomicString(); | 170 return name.toAtomicString(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 Frame* FrameTree::scopedChild(unsigned index) const | 173 Frame* FrameTree::scopedChild(unsigned index) const |
| 174 { | 174 { |
| 175 // TODO(dcheng, alexmos): Currently, all children of a RemoteFrame are | |
| 176 // visible, even through a shadow DOM scope. Once RemoteFrames have a | |
| 177 // TreeScope, it should be used here. | |
| 178 TreeScope* scope = nullptr; | |
| 179 if (m_thisFrame->isLocalFrame()) { | |
| 180 scope = toLocalFrame(m_thisFrame)->document(); | |
| 181 if (!scope) | |
| 182 return nullptr; | |
| 183 } | |
| 184 | |
| 185 unsigned scopedIndex = 0; | 175 unsigned scopedIndex = 0; |
| 186 for (Frame* result = firstChild(); result; result = result->tree().nextSibli
ng()) { | 176 for (Frame* child = firstChild(); child; child = child->tree().nextSibling()
) { |
| 187 // TODO(dcheng, alexmos): Currently, RemoteFrames are always visible, | 177 if (child->client()->inShadowTree()) |
| 188 // even through a shadow DOM scope. Once RemoteFrames have a TreeScope, | |
| 189 // the scoping check should apply to RemoteFrames too. | |
| 190 if (scope && result->isLocalFrame() && !toLocalFrame(result)->inScope(sc
ope)) | |
| 191 continue; | 178 continue; |
| 192 if (scopedIndex == index) | 179 if (scopedIndex == index) |
| 193 return result; | 180 return child; |
| 194 scopedIndex++; | 181 scopedIndex++; |
| 195 } | 182 } |
| 196 | 183 |
| 197 return nullptr; | 184 return nullptr; |
| 198 } | 185 } |
| 199 | 186 |
| 200 Frame* FrameTree::scopedChild(const AtomicString& name) const | 187 Frame* FrameTree::scopedChild(const AtomicString& name) const |
| 201 { | 188 { |
| 202 // TODO(dcheng, alexmos): Currently, all children of a RemoteFrame are | 189 for (Frame* child = firstChild(); child; child = child->tree().nextSibling()
) { |
| 203 // visible, even through a shadow DOM scope. Once RemoteFrames have a | 190 if (child->client()->inShadowTree()) |
| 204 // TreeScope, it should be used here. | 191 continue; |
| 205 TreeScope* scope = nullptr; | 192 if (child->tree().name() == name) |
| 206 if (m_thisFrame->isLocalFrame()) { | 193 return child; |
| 207 scope = toLocalFrame(m_thisFrame)->document(); | |
| 208 if (!scope) | |
| 209 return nullptr; | |
| 210 } | 194 } |
| 211 | |
| 212 for (Frame* child = firstChild(); child; child = child->tree().nextSibling()
) | |
| 213 // TODO(dcheng, alexmos): Currently, RemoteFrames are always visible, | |
| 214 // even through a shadow DOM scope. Once RemoteFrames have a TreeScope, | |
| 215 // the scoping check should apply to RemoteFrames too. | |
| 216 if (child->tree().name() == name && (!scope || !child->isLocalFrame() ||
toLocalFrame(child)->inScope(scope))) | |
| 217 return child; | |
| 218 return nullptr; | 195 return nullptr; |
| 219 } | 196 } |
| 220 | 197 |
| 221 inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const | 198 inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const |
| 222 { | 199 { |
| 223 // TODO(dcheng, alexmos): Once RemoteFrames have a TreeScope, this should | |
| 224 // return 0 if there is no scope. | |
| 225 | |
| 226 unsigned scopedCount = 0; | 200 unsigned scopedCount = 0; |
| 227 for (Frame* result = firstChild(); result; result = result->tree().nextSibli
ng()) { | 201 for (Frame* child = firstChild(); child; child = child->tree().nextSibling()
) { |
| 228 // FIXME: Currently, RemoteFrames are always visible, even through a sha
dow DOM scope. | 202 if (child->client()->inShadowTree()) |
| 229 // Once RemoteFrames have a TreeScope, the scoping check should apply to
RemoteFrames too. | |
| 230 if (scope && result->isLocalFrame() && !toLocalFrame(result)->inScope(sc
ope)) | |
| 231 continue; | 203 continue; |
| 232 scopedCount++; | 204 scopedCount++; |
| 233 } | 205 } |
| 234 | 206 |
| 235 return scopedCount; | 207 return scopedCount; |
| 236 } | 208 } |
| 237 | 209 |
| 238 unsigned FrameTree::scopedChildCount() const | 210 unsigned FrameTree::scopedChildCount() const |
| 239 { | 211 { |
| 240 if (m_scopedChildCount == invalidChildCount) { | 212 if (m_scopedChildCount == invalidChildCount) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 { | 410 { |
| 439 if (!frame) { | 411 if (!frame) { |
| 440 printf("Null input frame\n"); | 412 printf("Null input frame\n"); |
| 441 return; | 413 return; |
| 442 } | 414 } |
| 443 | 415 |
| 444 printFrames(frame->tree().top(), frame, 0); | 416 printFrames(frame->tree().top(), frame, 0); |
| 445 } | 417 } |
| 446 | 418 |
| 447 #endif | 419 #endif |
| OLD | NEW |