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

Unified Diff: Source/web/WebFrame.cpp

Issue 1119823003: Allow createLocalChild to specify previous sibling frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Change appendChild to use insertAfter Created 5 years, 8 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 | « no previous file | Source/web/WebRemoteFrameImpl.h » ('j') | Source/web/tests/WebFrameTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebFrame.cpp
diff --git a/Source/web/WebFrame.cpp b/Source/web/WebFrame.cpp
index ca855dca8a7f4a72e69996046ad8a91ae3dffd39..81efddf6bc4712f639f17164bcccc5ed02b2f25d 100644
--- a/Source/web/WebFrame.cpp
+++ b/Source/web/WebFrame.cpp
@@ -142,25 +142,40 @@ void WebFrame::setOpener(WebFrame* opener)
m_opener = opener;
}
-void WebFrame::appendChild(WebFrame* child)
+void WebFrame::insertAfter(WebFrame* newChild, WebFrame* previousSibling)
{
- // FIXME: Original code asserts that the frames have the same Page. We
- // should add an equivalent check... figure out what.
- child->m_parent = this;
- WebFrame* oldLast = m_lastChild;
- m_lastChild = child;
-
- if (oldLast) {
- child->m_previousSibling = oldLast;
- oldLast->m_nextSibling = child;
+ newChild->m_parent = this;
+
+ WebFrame* next;
+ if (!previousSibling) {
+ // Insert at the beginning if no previous sibling is specified.
+ next = m_firstChild;
+ m_firstChild = newChild;
+ } else {
+ ASSERT(previousSibling->m_parent == this);
+ next = previousSibling->m_nextSibling;
+ previousSibling->m_nextSibling = newChild;
+ newChild->m_previousSibling = previousSibling;
+ }
+
+ if (next) {
+ newChild->m_nextSibling = next;
+ next->m_previousSibling = newChild;
} else {
- m_firstChild = child;
+ m_lastChild = newChild;
}
toCoreFrame(this)->tree().invalidateScopedChildCount();
toCoreFrame(this)->host()->incrementSubframeCount();
}
+void WebFrame::appendChild(WebFrame* child)
+{
+ // TODO(dcheng): Original code asserts that the frames have the same Page.
+ // We should add an equivalent check... figure out what.
+ insertAfter(child, m_lastChild);
+}
+
void WebFrame::removeChild(WebFrame* child)
{
child->m_parent = 0;
« no previous file with comments | « no previous file | Source/web/WebRemoteFrameImpl.h » ('j') | Source/web/tests/WebFrameTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698