Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void FrameTree::setName(const AtomicString& name, const AtomicString& fallbackNa me) | 54 void FrameTree::setName(const AtomicString& name, const AtomicString& fallbackNa me) |
| 55 { | 55 { |
| 56 m_name = name; | 56 m_name = name; |
| 57 if (!parent()) { | 57 if (!parent()) { |
| 58 m_uniqueName = name; | 58 m_uniqueName = name; |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 m_uniqueName = AtomicString(); // Remove our old frame name so it's not cons idered in uniqueChildName. | 61 m_uniqueName = AtomicString(); // Remove our old frame name so it's not cons idered in uniqueChildName. |
|
alexmos
2016/02/10 00:46:46
Update function name in comment?
Łukasz Anforowicz
2016/02/10 22:10:51
Ooops - thanks for catching this. Done.
| |
| 62 m_uniqueName = parent()->tree().uniqueChildName(name.isEmpty() ? fallbackNam e : name); | 62 m_uniqueName = parent()->tree().calculateUniqueNameForChildFrame(true, name, fallbackName); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void FrameTree::setNameForReplacementFrame(const AtomicString& name, const Atomi cString& uniqueName) | 65 void FrameTree::setNameForReplacementFrame(const AtomicString& name, const Atomi cString& uniqueName) |
| 66 { | 66 { |
| 67 m_name = name; | 67 m_name = name; |
| 68 m_uniqueName = uniqueName; | 68 m_uniqueName = uniqueName; |
| 69 } | 69 } |
| 70 | 70 |
| 71 Frame* FrameTree::parent() const | 71 Frame* FrameTree::parent() const |
| 72 { | 72 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 | 116 |
| 117 bool FrameTree::uniqueNameExists(const AtomicString& name) const | 117 bool FrameTree::uniqueNameExists(const AtomicString& name) const |
| 118 { | 118 { |
| 119 for (Frame* frame = top(); frame; frame = frame->tree().traverseNext()) { | 119 for (Frame* frame = top(); frame; frame = frame->tree().traverseNext()) { |
| 120 if (frame->tree().uniqueName() == name) | 120 if (frame->tree().uniqueName() == name) |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const | 126 AtomicString FrameTree::calculateUniqueNameForNewChildFrame( |
| 127 const AtomicString& name, | |
| 128 const AtomicString& fallbackName) const | |
| 127 { | 129 { |
| 130 return calculateUniqueNameForChildFrame(false, name, fallbackName); | |
| 131 } | |
| 132 | |
| 133 AtomicString FrameTree::calculateUniqueNameForChildFrame( | |
| 134 bool existingChildFrame, | |
| 135 const AtomicString& originalRequestedName, | |
| 136 const AtomicString& fallbackName) const | |
| 137 { | |
| 138 const AtomicString& requestedName = | |
| 139 originalRequestedName.isEmpty() ? fallbackName : originalRequestedName; | |
| 128 if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requeste dName != "_blank") | 140 if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requeste dName != "_blank") |
| 129 return requestedName; | 141 return requestedName; |
| 130 | 142 |
| 131 // Create a repeatable name for a child about to be added to us. The name mu st be | 143 // Create a repeatable name for a child about to be added to us. The name mu st be |
| 132 // unique within the frame tree. The string we generate includes a "path" of names | 144 // unique within the frame tree. The string we generate includes a "path" of names |
| 133 // from the root frame down to us. For this path to be unique, each set of s iblings must | 145 // from the root frame down to us. For this path to be unique, each set of s iblings must |
| 134 // contribute a unique name to the path, which can't collide with any HTML-a ssigned names. | 146 // contribute a unique name to the path, which can't collide with any HTML-a ssigned names. |
| 135 // We generate this path component by index in the child list along with an unlikely | 147 // We generate this path component by index in the child list along with an unlikely |
| 136 // frame name that can't be set in HTML because it collides with comment syn tax. | 148 // frame name that can't be set in HTML because it collides with comment syn tax. |
| 137 | 149 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 153 name.append(frame->tree().uniqueName().string().substring(framePathPrefi xLength, | 165 name.append(frame->tree().uniqueName().string().substring(framePathPrefi xLength, |
| 154 frame->tree().uniqueName().length() - framePathPrefixLength - frameP athSuffixLength)); | 166 frame->tree().uniqueName().length() - framePathPrefixLength - frameP athSuffixLength)); |
| 155 } | 167 } |
| 156 for (int i = chain.size() - 1; i >= 0; --i) { | 168 for (int i = chain.size() - 1; i >= 0; --i) { |
| 157 frame = chain[i]; | 169 frame = chain[i]; |
| 158 name.append('/'); | 170 name.append('/'); |
| 159 name.append(frame->tree().uniqueName()); | 171 name.append(frame->tree().uniqueName()); |
| 160 } | 172 } |
| 161 | 173 |
| 162 name.appendLiteral("/<!--frame"); | 174 name.appendLiteral("/<!--frame"); |
| 163 name.appendNumber(childCount() - 1); | 175 name.appendNumber(childCount() - (existingChildFrame ? 1 : 0)); |
| 164 name.appendLiteral("-->-->"); | 176 name.appendLiteral("-->-->"); |
| 165 | 177 |
| 166 return name.toAtomicString(); | 178 return name.toAtomicString(); |
| 167 } | 179 } |
| 168 | 180 |
| 169 Frame* FrameTree::scopedChild(unsigned index) const | 181 Frame* FrameTree::scopedChild(unsigned index) const |
| 170 { | 182 { |
| 171 unsigned scopedIndex = 0; | 183 unsigned scopedIndex = 0; |
| 172 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { | 184 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { |
| 173 if (child->client()->inShadowTree()) | 185 if (child->client()->inShadowTree()) |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 { | 414 { |
| 403 if (!frame) { | 415 if (!frame) { |
| 404 printf("Null input frame\n"); | 416 printf("Null input frame\n"); |
| 405 return; | 417 return; |
| 406 } | 418 } |
| 407 | 419 |
| 408 printFrames(frame->tree().top(), frame, 0); | 420 printFrames(frame->tree().top(), frame, 0); |
| 409 } | 421 } |
| 410 | 422 |
| 411 #endif | 423 #endif |
| OLD | NEW |