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

Unified Diff: third_party/WebKit/Source/core/page/FrameTree.cpp

Issue 2053903002: Returning early when setting a frame name to the same name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replacing part of short-circuiting condition with just an assert. Created 4 years, 6 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
Index: third_party/WebKit/Source/core/page/FrameTree.cpp
diff --git a/third_party/WebKit/Source/core/page/FrameTree.cpp b/third_party/WebKit/Source/core/page/FrameTree.cpp
index 827cbb629e79a1ef1051c50fd41c00950a8d6f15..4b6e9d17b45d0d3ea6719c58cd470ee2c0147b38 100644
--- a/third_party/WebKit/Source/core/page/FrameTree.cpp
+++ b/third_party/WebKit/Source/core/page/FrameTree.cpp
@@ -54,6 +54,20 @@ FrameTree::~FrameTree()
void FrameTree::setName(const AtomicString& name)
{
+ // Do not recalculate m_uniqueName if there is no real change of m_name.
+ // This is not just a performance optimization - other code relies on the
+ // assumption that unique name shouldn't change if the assigned name didn't
+ // change (i.e. code in content::FrameTreeNode::SetFrameName).
+ if (m_name == name) {
+ // Assert that returning early below won't leave m_uniqueName in an
+ // uninitialized state - it should only be null if m_name is also
+ // null and only if it is for the main frame.
+ // m_uniqueName.isNull() should imply m_name.isNull() && !parent().
+ // this FrameTree is for a main frame.
+ DCHECK(!m_uniqueName.isNull() || (m_name.isNull() && !parent()));
+ return;
+ }
+
m_name = name;
// Remove our old frame name so it's not considered in calculateUniqueNameForChildFrame

Powered by Google App Engine
This is Rietveld 408576698