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

Unified Diff: content/browser/frame_host/navigation_entry_impl.cc

Issue 2191543003: Remove existing FrameNavigationEntry when new named frame is added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra pointer in test. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_entry_impl.cc
diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc
index c50a8d2229e498f4d6bb709429192ba6f0c4a057..c3e45e6bc5b4b8d299c65c68aef0d7c2102d8d92 100644
--- a/content/browser/frame_host/navigation_entry_impl.cc
+++ b/content/browser/frame_host/navigation_entry_impl.cc
@@ -99,6 +99,29 @@ void RecursivelyGenerateFrameState(
}
}
+// Walk the ancestor chain for both the |frame_tree_node| and the |node|.
+// Comparing the inputs directly is not performed, as this method assumes they
+// already match each other. Returns false if a mismatch in unique name or
+// ancestor chain is detected, otherwise true.
+bool InSameTreePosition(FrameTreeNode* frame_tree_node,
+ NavigationEntryImpl::TreeNode* node) {
+ FrameTreeNode* ftn = frame_tree_node->parent();
+ NavigationEntryImpl::TreeNode* current_node = node->parent;
+ while (ftn && current_node) {
+ if (!current_node->MatchesFrame(ftn))
+ return false;
+
+ if ((!current_node->parent && ftn->parent()) ||
+ (current_node->parent && !ftn->parent())) {
+ return false;
+ }
+
+ ftn = ftn->parent();
+ current_node = current_node->parent;
+ }
+ return true;
+}
+
} // namespace
int NavigationEntryImpl::kInvalidBindings = -1;
@@ -810,6 +833,43 @@ void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
tree_node->children.clear();
}
+void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame(
+ FrameTreeNode* frame_tree_node) {
+ DCHECK(!frame_tree_node->IsMainFrame());
+
+ NavigationEntryImpl::TreeNode* node = nullptr;
+ std::queue<NavigationEntryImpl::TreeNode*> work_queue;
+ int count = 0;
+
+ work_queue.push(root_node());
+ while (!work_queue.empty()) {
+ node = work_queue.front();
+ work_queue.pop();
+
+ // Enqueue any children and keep looking if the current node doesn't match.
+ if (!node->MatchesFrame(frame_tree_node)) {
+ for (auto* child : node->children) {
+ work_queue.push(child);
+ }
+ continue;
+ }
+
+ // Remove the node from the tree if it is not in the same position in the
+ // tree of FrameNavigationEntries and the FrameTree.
+ if (!InSameTreePosition(frame_tree_node, node)) {
+ NavigationEntryImpl::TreeNode* parent_node = node->parent;
+ auto it = std::find(parent_node->children.begin(),
+ parent_node->children.end(), node);
+ CHECK(it != parent_node->children.end());
+ parent_node->children.erase(it);
+ }
+ ++count;
+ }
+
+ // At most one match is expected, since it is based on unique frame name.
+ DCHECK_LE(count, 1);
+}
+
void NavigationEntryImpl::SetScreenshotPNGData(
scoped_refptr<base::RefCountedBytes> png_data) {
screenshot_ = png_data;
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698