Chromium Code Reviews| Index: Source/web/WebFrame.cpp |
| diff --git a/Source/web/WebFrame.cpp b/Source/web/WebFrame.cpp |
| index acad3e4bc27c6bb7c8218faf64a65c3b84a487d2..accb8a8c187b7bc5aca37dc7d9e457cb7ca6e3cc 100644 |
| --- a/Source/web/WebFrame.cpp |
| +++ b/Source/web/WebFrame.cpp |
| @@ -6,9 +6,41 @@ |
| #include "public/web/WebFrame.h" |
| #include "web/OpenedFrameTracker.h" |
| +#include <algorithm> |
| + |
| namespace blink { |
| +void WebFrame::swap(WebFrame* frame) |
| +{ |
| + using std::swap; |
| + |
| + if (m_parent) { |
| + if (m_parent->m_firstChild == this) |
|
eseidel
2014/05/08 00:13:01
I probably would have written a overrideIfSetTo(m_
dcheng
2014/05/08 01:54:18
Yeah I think it may not be worth it at the moment.
|
| + m_parent->m_firstChild = frame; |
| + if (m_parent->m_lastChild == this) |
| + m_parent->m_lastChild = frame; |
| + swap(m_parent, frame->m_parent); |
| + } |
| + if (m_previousSibling) { |
| + m_previousSibling->m_nextSibling = frame; |
| + swap(m_previousSibling, frame->m_previousSibling); |
| + } |
| + if (m_nextSibling) { |
| + m_nextSibling->m_previousSibling = frame; |
| + swap(m_nextSibling, frame->m_nextSibling); |
| + } |
| + if (m_opener) { |
| + m_opener->m_openedFrameTracker->remove(this); |
| + m_opener->m_openedFrameTracker->add(frame); |
| + swap(m_opener, frame->m_opener); |
| + } |
| + if (!m_openedFrameTracker->isEmpty()) { |
| + m_openedFrameTracker->updateOpener(frame); |
| + frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); |
| + } |
| +} |
| + |
| WebFrame* WebFrame::opener() const |
| { |
| return m_opener; |