Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Side by Side Diff: Source/core/page/HistoryController.cpp

Issue 139103003: Reland "Remove children from HistoryNodes that redirect during back/forward navigation" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make trybots happy Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/HistoryController.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 : m_entry(entry) 75 : m_entry(entry)
76 , m_value(value) 76 , m_value(value)
77 { 77 {
78 m_entry->m_framesToItems.add(value->targetFrameID(), this); 78 m_entry->m_framesToItems.add(value->targetFrameID(), this);
79 String target = value->target(); 79 String target = value->target();
80 if (target.isNull()) 80 if (target.isNull())
81 target = emptyString(); 81 target = emptyString();
82 m_entry->m_uniqueNamesToItems.add(target, this); 82 m_entry->m_uniqueNamesToItems.add(target, this);
83 } 83 }
84 84
85 void HistoryNode::removeChildren()
86 {
87 // FIXME: This is inefficient. Figure out a cleaner way to ensure this Histo ryNode isn't cached anywhere.
88 for (unsigned i = 0; i < m_children.size(); i++) {
89 m_children[i]->removeChildren();
90
91 HashMap<uint64_t, HistoryNode*>::iterator framesEnd = m_entry->m_framesT oItems.end();
92 HashMap<String, HistoryNode*>::iterator uniqueNamesEnd = m_entry->m_uniq ueNamesToItems.end();
93 for (HashMap<uint64_t, HistoryNode*>::iterator it = m_entry->m_framesToI tems.begin(); it != framesEnd; ++it) {
94 if (it->value == m_children[i])
95 m_entry->m_framesToItems.remove(it);
96 }
97 for (HashMap<String, HistoryNode*>::iterator it = m_entry->m_uniqueNames ToItems.begin(); it != uniqueNamesEnd; ++it) {
98 if (it->value == m_children[i])
99 m_entry->m_uniqueNamesToItems.remove(it);
100 }
101 }
102 m_children.clear();
103 }
104
85 HistoryEntry::HistoryEntry(HistoryItem* root) 105 HistoryEntry::HistoryEntry(HistoryItem* root)
86 { 106 {
87 m_root = HistoryNode::create(this, root); 107 m_root = HistoryNode::create(this, root);
88 } 108 }
89 109
90 PassOwnPtr<HistoryEntry> HistoryEntry::create(HistoryItem* root) 110 PassOwnPtr<HistoryEntry> HistoryEntry::create(HistoryItem* root)
91 { 111 {
92 return adoptPtr(new HistoryEntry(root)); 112 return adoptPtr(new HistoryEntry(root));
93 } 113 }
94 114
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (!m_previousEntry) 290 if (!m_previousEntry)
271 return 0; 291 return 0;
272 return itemForExport(m_previousEntry->rootHistoryNode()); 292 return itemForExport(m_previousEntry->rootHistoryNode());
273 } 293 }
274 294
275 HistoryItem* HistoryController::itemForNewChildFrame(Frame* frame) const 295 HistoryItem* HistoryController::itemForNewChildFrame(Frame* frame) const
276 { 296 {
277 return m_currentEntry ? m_currentEntry->itemForFrame(frame) : 0; 297 return m_currentEntry ? m_currentEntry->itemForFrame(frame) : 0;
278 } 298 }
279 299
300 void HistoryController::removeChildrenForRedirect(Frame* frame)
301 {
302 if (!m_provisionalEntry)
303 return;
304 if (HistoryNode* node = m_provisionalEntry->historyNodeForFrame(frame))
305 node->removeChildren();
306 }
307
280 void HistoryController::createNewBackForwardItem(Frame* targetFrame, HistoryItem * item, bool clipAtTarget) 308 void HistoryController::createNewBackForwardItem(Frame* targetFrame, HistoryItem * item, bool clipAtTarget)
281 { 309 {
282 RefPtr<HistoryItem> newItem = item; 310 RefPtr<HistoryItem> newItem = item;
283 if (!m_currentEntry) { 311 if (!m_currentEntry) {
284 m_currentEntry = HistoryEntry::create(newItem.get()); 312 m_currentEntry = HistoryEntry::create(newItem.get());
285 } else { 313 } else {
286 HistoryItem* oldItem = m_currentEntry->itemForFrame(targetFrame); 314 HistoryItem* oldItem = m_currentEntry->itemForFrame(targetFrame);
287 if (!clipAtTarget && oldItem) 315 if (!clipAtTarget && oldItem)
288 newItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber() ); 316 newItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber() );
289 m_previousEntry = m_currentEntry.release(); 317 m_previousEntry = m_currentEntry.release();
290 m_currentEntry = m_previousEntry->cloneAndReplace(newItem.get(), clipAtT arget, targetFrame, m_page); 318 m_currentEntry = m_previousEntry->cloneAndReplace(newItem.get(), clipAtT arget, targetFrame, m_page);
291 } 319 }
292 } 320 }
293 321
294 } // namespace WebCore 322 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/HistoryController.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698