OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 m_entry->m_framesToItems.add(frameID, this); | 76 m_entry->m_framesToItems.add(frameID, this); |
77 String target = value->target(); | 77 String target = value->target(); |
78 if (target.isNull()) | 78 if (target.isNull()) |
79 target = emptyString(); | 79 target = emptyString(); |
80 m_entry->m_uniqueNamesToItems.add(target, this); | 80 m_entry->m_uniqueNamesToItems.add(target, this); |
81 } | 81 } |
82 | 82 |
83 void HistoryNode::removeChildren() | 83 void HistoryNode::removeChildren() |
84 { | 84 { |
85 // FIXME: This is inefficient. Figure out a cleaner way to ensure this Histo
ryNode isn't cached anywhere. | 85 // FIXME: This is inefficient. Figure out a cleaner way to ensure this Histo
ryNode isn't cached anywhere. |
| 86 // We need these vectors because you can't remove things from |
| 87 // collections you are iterating over. |
| 88 Vector<uint64_t, 10> framesToRemove; |
| 89 Vector<String, 10> uniqueNamesToRemove; |
86 for (unsigned i = 0; i < m_children.size(); i++) { | 90 for (unsigned i = 0; i < m_children.size(); i++) { |
87 m_children[i]->removeChildren(); | 91 m_children[i]->removeChildren(); |
88 | 92 |
89 HashMap<uint64_t, HistoryNode*>::iterator framesEnd = m_entry->m_framesT
oItems.end(); | 93 HashMap<uint64_t, HistoryNode*>::iterator framesEnd = m_entry->m_framesT
oItems.end(); |
90 HashMap<String, HistoryNode*>::iterator uniqueNamesEnd = m_entry->m_uniq
ueNamesToItems.end(); | 94 HashMap<String, HistoryNode*>::iterator uniqueNamesEnd = m_entry->m_uniq
ueNamesToItems.end(); |
91 for (HashMap<uint64_t, HistoryNode*>::iterator it = m_entry->m_framesToI
tems.begin(); it != framesEnd; ++it) { | 95 for (HashMap<uint64_t, HistoryNode*>::iterator it = m_entry->m_framesToI
tems.begin(); it != framesEnd; ++it) { |
92 if (it->value == m_children[i]) | 96 if (it->value == m_children[i]) |
93 m_entry->m_framesToItems.remove(it); | 97 framesToRemove.append(it->key); |
94 } | 98 } |
95 for (HashMap<String, HistoryNode*>::iterator it = m_entry->m_uniqueNames
ToItems.begin(); it != uniqueNamesEnd; ++it) { | 99 for (HashMap<String, HistoryNode*>::iterator it = m_entry->m_uniqueNames
ToItems.begin(); it != uniqueNamesEnd; ++it) { |
96 if (it->value == m_children[i]) | 100 if (it->value == m_children[i]) |
97 m_entry->m_uniqueNamesToItems.remove(it); | 101 uniqueNamesToRemove.append(it->key); |
98 } | 102 } |
99 } | 103 } |
| 104 for (unsigned i = 0; i < framesToRemove.size(); i++) |
| 105 m_entry->m_framesToItems.remove(framesToRemove[i]); |
| 106 for (unsigned i = 0; i < uniqueNamesToRemove.size(); i++) |
| 107 m_entry->m_uniqueNamesToItems.remove(uniqueNamesToRemove[i]); |
100 m_children.clear(); | 108 m_children.clear(); |
101 } | 109 } |
102 | 110 |
103 HistoryEntry::HistoryEntry(HistoryItem* root, int64_t frameID) | 111 HistoryEntry::HistoryEntry(HistoryItem* root, int64_t frameID) |
104 { | 112 { |
105 m_root = HistoryNode::create(this, root, frameID); | 113 m_root = HistoryNode::create(this, root, frameID); |
106 } | 114 } |
107 | 115 |
108 PassOwnPtr<HistoryEntry> HistoryEntry::create(HistoryItem* root, int64_t frameID
) | 116 PassOwnPtr<HistoryEntry> HistoryEntry::create(HistoryItem* root, int64_t frameID
) |
109 { | 117 { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } else { | 305 } else { |
298 HistoryItem* oldItem = m_currentEntry->itemForFrame(targetFrame); | 306 HistoryItem* oldItem = m_currentEntry->itemForFrame(targetFrame); |
299 if (!clipAtTarget && oldItem) | 307 if (!clipAtTarget && oldItem) |
300 newItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber()
); | 308 newItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber()
); |
301 m_previousEntry = m_currentEntry.release(); | 309 m_previousEntry = m_currentEntry.release(); |
302 m_currentEntry = m_previousEntry->cloneAndReplace(newItem.get(), clipAtT
arget, targetFrame, m_page); | 310 m_currentEntry = m_previousEntry->cloneAndReplace(newItem.get(), clipAtT
arget, targetFrame, m_page); |
303 } | 311 } |
304 } | 312 } |
305 | 313 |
306 } // namespace WebCore | 314 } // namespace WebCore |
OLD | NEW |