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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 void FrameTree::setName(const AtomicString& name) | 55 void FrameTree::setName(const AtomicString& name) |
56 { | 56 { |
57 // This method should only be called for local frames | 57 // This method should only be called for local frames |
58 // (remote frames should be updated via setPrecalculatedName). | 58 // (remote frames should be updated via setPrecalculatedName). |
59 DCHECK(m_thisFrame->isLocalFrame()); | 59 DCHECK(m_thisFrame->isLocalFrame()); |
60 | 60 |
61 // When this method is called, m_uniqueName should be already initialized. | 61 // When this method is called, m_uniqueName should be already initialized. |
62 // This assert helps ensure that early return (a few lines below) won't | 62 // This assert helps ensure that early return (a few lines below) won't |
63 // result in an uninitialized m_uniqueName. | 63 // result in an uninitialized m_uniqueName. |
64 DCHECK(!m_uniqueName.isNull() | 64 DCHECK(!m_uniqueName.isNull() |
65 || (m_uniqueName.isNull() && m_name.isNull() && !parent())); | 65 || (m_uniqueName.isNull() && !parent())); |
Łukasz Anforowicz
2016/09/09 16:21:38
m_name and m_uniqueName are no longer in-sync now
| |
66 | 66 |
67 // Do not recalculate m_uniqueName if there is no real change of m_name. | 67 // Do not recalculate m_uniqueName if there is no real change of m_name. |
68 // This is not just a performance optimization - other code relies on the | 68 // This is not just a performance optimization - other code relies on the |
69 // assumption that unique name shouldn't change if the assigned name didn't | 69 // assumption that unique name shouldn't change if the assigned name didn't |
70 // change (i.e. code in content::FrameTreeNode::SetFrameName). | 70 // change (i.e. code in content::FrameTreeNode::SetFrameName). |
71 if (m_name == name) | 71 if (m_name == name) |
72 return; | 72 return; |
73 | 73 |
74 m_name = name; | 74 m_name = name; |
75 | 75 |
76 // Remove our old frame name so it's not considered in calculateUniqueNameFo rChildFrame | 76 // https://crbug.com/607205: Make sure m_uniqueName doesn't change after |
77 // and appendUniqueSuffix calls below. | 77 // initial navigation - session history depends on this. |
78 if (toLocalFrame(m_thisFrame)->loader().stateMachine()->committedFirstRealDo cumentLoad()) | |
79 return; | |
80 | |
81 // Leave main frame's unique name set to a null string. | |
82 if (!parent()) | |
83 return; | |
Łukasz Anforowicz
2016/09/09 16:21:38
I was wondering whether it might be a good idea to
dcheng
2016/09/09 22:00:13
I think this is fine (and if they're using it, tha
| |
84 | |
85 // Remove our old frame name so it's not considered in | |
86 // calculateUniqueNameForChildFrame call below. | |
78 m_uniqueName = AtomicString(); | 87 m_uniqueName = AtomicString(); |
79 | 88 |
80 // Calculate a new unique name based on inputs. | 89 // Calculate a new unique name based on inputs. |
81 if (parent()) { | 90 setUniqueName( |
82 setUniqueName( | 91 parent()->tree().calculateUniqueNameForChildFrame(m_thisFrame, name, nul lAtom)); |
83 parent()->tree().calculateUniqueNameForChildFrame(m_thisFrame, name, nullAtom)); | |
84 } else if (name.isEmpty() || !uniqueNameExists(name)) { | |
85 // Only main frame can have an empty unique name, so for main frames | |
86 // emptiness guarantees uniquness. | |
87 setUniqueName(name); | |
88 } else { | |
89 setUniqueName(appendUniqueSuffix(name, "<!--framePosition")); | |
90 } | |
91 } | 92 } |
92 | 93 |
93 void FrameTree::setPrecalculatedName(const AtomicString& name, const AtomicStrin g& uniqueName) | 94 void FrameTree::setPrecalculatedName(const AtomicString& name, const AtomicStrin g& uniqueName) |
94 { | 95 { |
95 if (!parent()) { | 96 m_name = name; |
96 DCHECK(uniqueName == name); | |
Łukasz Anforowicz
2016/09/09 16:21:38
We can no longer have the DCHECK above, because af
| |
97 } else { | |
98 DCHECK(!uniqueName.isEmpty()); | |
99 } | |
100 | 97 |
101 m_name = name; | 98 // Non-main frames should have a non-empty unique name. |
99 DCHECK(!parent() || !uniqueName.isEmpty()); | |
102 | 100 |
103 // TODO(lukasza): We would like to assert uniqueness below (i.e. by calling | 101 // TODO(lukasza): We would like to assert uniqueness below (i.e. by calling |
104 // setUniqueName), but | 102 // setUniqueName), but |
105 // 1) uniqueness is currently violated by provisional/old frame pairs. | 103 // 1) uniqueness is currently violated by provisional/old frame pairs. |
106 // 2) there is an unresolved race between 2 OOPIFs, that can result in a | 104 // 2) there is an unresolved race between 2 OOPIFs, that can result in a |
107 // non-unique |uniqueName| - see https://crbug.com/558680#c14. | 105 // non-unique |uniqueName| - see https://crbug.com/558680#c14. |
108 m_uniqueName = uniqueName; | 106 m_uniqueName = uniqueName; |
109 } | 107 } |
110 | 108 |
111 Frame* FrameTree::parent() const | 109 Frame* FrameTree::parent() const |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 { | 592 { |
595 if (!frame) { | 593 if (!frame) { |
596 printf("Null input frame\n"); | 594 printf("Null input frame\n"); |
597 return; | 595 return; |
598 } | 596 } |
599 | 597 |
600 printFrames(frame->tree().top(), frame, 0); | 598 printFrames(frame->tree().top(), frame, 0); |
601 } | 599 } |
602 | 600 |
603 #endif | 601 #endif |
OLD | NEW |