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 |
| 62 m_uniqueName = parent()->tree().uniqueChildName(name.isEmpty() ? fallbackNam e : name); | 62 // Remove our old frame name so it's not considered in calculateUniqueNameFo rChildFrame. |
| 63 m_uniqueName = AtomicString(); | |
| 64 | |
| 65 m_uniqueName = parent()->tree().calculateUniqueNameForChildFrame(true, name, fallbackName); | |
| 63 } | 66 } |
| 64 | 67 |
| 65 void FrameTree::setNameForReplacementFrame(const AtomicString& name, const Atomi cString& uniqueName) | 68 void FrameTree::setReplicatedName(const AtomicString& name, const AtomicString& uniqueName) |
| 66 { | 69 { |
| 70 if (!parent()) { | |
| 71 ASSERT(uniqueName == name); | |
| 72 } else { | |
| 73 ASSERT(!uniqueName.isEmpty()); | |
| 74 } | |
| 75 | |
| 67 m_name = name; | 76 m_name = name; |
| 68 m_uniqueName = uniqueName; | 77 m_uniqueName = uniqueName; |
| 69 } | 78 } |
| 70 | 79 |
| 71 Frame* FrameTree::parent() const | 80 Frame* FrameTree::parent() const |
| 72 { | 81 { |
| 73 if (!m_thisFrame->client()) | 82 if (!m_thisFrame->client()) |
| 74 return nullptr; | 83 return nullptr; |
| 75 return m_thisFrame->client()->parent(); | 84 return m_thisFrame->client()->parent(); |
| 76 } | 85 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 | 125 |
| 117 bool FrameTree::uniqueNameExists(const AtomicString& name) const | 126 bool FrameTree::uniqueNameExists(const AtomicString& name) const |
| 118 { | 127 { |
| 119 for (Frame* frame = top(); frame; frame = frame->tree().traverseNext()) { | 128 for (Frame* frame = top(); frame; frame = frame->tree().traverseNext()) { |
| 120 if (frame->tree().uniqueName() == name) | 129 if (frame->tree().uniqueName() == name) |
| 121 return true; | 130 return true; |
| 122 } | 131 } |
| 123 return false; | 132 return false; |
| 124 } | 133 } |
| 125 | 134 |
| 126 AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const | 135 AtomicString FrameTree::calculateUniqueNameForNewChildFrame( |
| 136 const AtomicString& name, | |
| 137 const AtomicString& fallbackName) const | |
| 127 { | 138 { |
| 139 return calculateUniqueNameForChildFrame(false, name, fallbackName); | |
| 140 } | |
| 141 | |
| 142 AtomicString FrameTree::calculateUniqueNameForChildFrame( | |
| 143 bool existingChildFrame, | |
| 144 const AtomicString& originalRequestedName, | |
| 145 const AtomicString& fallbackName) const | |
| 146 { | |
| 147 const AtomicString& requestedName = | |
| 148 originalRequestedName.isEmpty() ? fallbackName : originalRequestedName; | |
| 128 if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requeste dName != "_blank") | 149 if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requeste dName != "_blank") |
| 129 return requestedName; | 150 return requestedName; |
| 130 | 151 |
| 131 // Create a repeatable name for a child about to be added to us. The name mu st be | 152 // 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 | 153 // 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 | 154 // 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. | 155 // 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 | 156 // 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. | 157 // frame name that can't be set in HTML because it collides with comment syn tax. |
| 137 | 158 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 153 name.append(frame->tree().uniqueName().string().substring(framePathPrefi xLength, | 174 name.append(frame->tree().uniqueName().string().substring(framePathPrefi xLength, |
| 154 frame->tree().uniqueName().length() - framePathPrefixLength - frameP athSuffixLength)); | 175 frame->tree().uniqueName().length() - framePathPrefixLength - frameP athSuffixLength)); |
| 155 } | 176 } |
| 156 for (int i = chain.size() - 1; i >= 0; --i) { | 177 for (int i = chain.size() - 1; i >= 0; --i) { |
| 157 frame = chain[i]; | 178 frame = chain[i]; |
| 158 name.append('/'); | 179 name.append('/'); |
| 159 name.append(frame->tree().uniqueName()); | 180 name.append(frame->tree().uniqueName()); |
| 160 } | 181 } |
| 161 | 182 |
| 162 name.appendLiteral("/<!--frame"); | 183 name.appendLiteral("/<!--frame"); |
| 163 name.appendNumber(childCount() - 1); | 184 name.appendNumber(childCount() - (existingChildFrame ? 1 : 0)); |
|
dcheng
2016/02/16 22:17:29
Is it possible to pull the FrameTree changes into
Łukasz Anforowicz
2016/02/16 23:39:53
I think it is not possible.
1. I've added propaga
| |
| 164 name.appendLiteral("-->-->"); | 185 name.appendLiteral("-->-->"); |
| 165 | 186 |
| 166 return name.toAtomicString(); | 187 return name.toAtomicString(); |
| 167 } | 188 } |
| 168 | 189 |
| 169 Frame* FrameTree::scopedChild(unsigned index) const | 190 Frame* FrameTree::scopedChild(unsigned index) const |
| 170 { | 191 { |
| 171 unsigned scopedIndex = 0; | 192 unsigned scopedIndex = 0; |
| 172 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { | 193 for (Frame* child = firstChild(); child; child = child->tree().nextSibling() ) { |
| 173 if (child->client()->inShadowTree()) | 194 if (child->client()->inShadowTree()) |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 { | 423 { |
| 403 if (!frame) { | 424 if (!frame) { |
| 404 printf("Null input frame\n"); | 425 printf("Null input frame\n"); |
| 405 return; | 426 return; |
| 406 } | 427 } |
| 407 | 428 |
| 408 printFrames(frame->tree().top(), frame, 0); | 429 printFrames(frame->tree().top(), frame, 0); |
| 409 } | 430 } |
| 410 | 431 |
| 411 #endif | 432 #endif |
| OLD | NEW |