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

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

Issue 1635873003: Replicating WebFrame::uniqueName across renderers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dump-render-tree3
Patch Set: Rebasing... Created 4 years, 10 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 a4816ad06203d02d9e3da21a00efa598bef03ea6..137818292e05459b6a3b480bbe0570a0a001a628 100644
--- a/third_party/WebKit/Source/core/page/FrameTree.cpp
+++ b/third_party/WebKit/Source/core/page/FrameTree.cpp
@@ -58,12 +58,21 @@ void FrameTree::setName(const AtomicString& name, const AtomicString& fallbackNa
m_uniqueName = name;
return;
}
- m_uniqueName = AtomicString(); // Remove our old frame name so it's not considered in uniqueChildName.
- m_uniqueName = parent()->tree().uniqueChildName(name.isEmpty() ? fallbackName : name);
+
+ // Remove our old frame name so it's not considered in calculateUniqueNameForChildFrame.
+ m_uniqueName = AtomicString();
+
+ m_uniqueName = parent()->tree().calculateUniqueNameForChildFrame(true, name, fallbackName);
}
-void FrameTree::setNameForReplacementFrame(const AtomicString& name, const AtomicString& uniqueName)
+void FrameTree::setPrecalculatedName(const AtomicString& name, const AtomicString& uniqueName)
{
+ if (!parent()) {
+ ASSERT(uniqueName == name);
+ } else {
+ ASSERT(!uniqueName.isEmpty());
+ }
+
m_name = name;
m_uniqueName = uniqueName;
}
@@ -123,8 +132,19 @@ bool FrameTree::uniqueNameExists(const AtomicString& name) const
return false;
}
-AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const
+AtomicString FrameTree::calculateUniqueNameForNewChildFrame(
+ const AtomicString& name,
+ const AtomicString& fallbackName) const
+{
+ return calculateUniqueNameForChildFrame(false, name, fallbackName);
+}
+
+AtomicString FrameTree::calculateUniqueNameForChildFrame(
+ bool existingChildFrame,
+ const AtomicString& name,
+ const AtomicString& fallbackName) const
{
+ const AtomicString& requestedName = name.isEmpty() ? fallbackName : name;
if (!requestedName.isEmpty() && !uniqueNameExists(requestedName) && requestedName != "_blank")
return requestedName;
@@ -147,23 +167,23 @@ AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const
break;
chain.append(frame);
}
- StringBuilder name;
- name.append(framePathPrefix);
+ StringBuilder uniqueName;
+ uniqueName.append(framePathPrefix);
if (frame) {
- name.append(frame->tree().uniqueName().string().substring(framePathPrefixLength,
+ uniqueName.append(frame->tree().uniqueName().string().substring(framePathPrefixLength,
frame->tree().uniqueName().length() - framePathPrefixLength - framePathSuffixLength));
}
for (int i = chain.size() - 1; i >= 0; --i) {
frame = chain[i];
- name.append('/');
- name.append(frame->tree().uniqueName());
+ uniqueName.append('/');
+ uniqueName.append(frame->tree().uniqueName());
}
- name.appendLiteral("/<!--frame");
- name.appendNumber(childCount() - 1);
- name.appendLiteral("-->-->");
+ uniqueName.appendLiteral("/<!--frame");
+ uniqueName.appendNumber(childCount() - (existingChildFrame ? 1 : 0));
+ uniqueName.appendLiteral("-->-->");
- return name.toAtomicString();
+ return uniqueName.toAtomicString();
}
Frame* FrameTree::scopedChild(unsigned index) const
« no previous file with comments | « third_party/WebKit/Source/core/page/FrameTree.h ('k') | third_party/WebKit/Source/web/FrameLoaderClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698