| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "public/web/WebFrame.h" | 6 #include "public/web/WebFrame.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/WindowProxyManager.h" | 8 #include "bindings/core/v8/WindowProxyManager.h" |
| 9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 void WebFrame::setOpener(WebFrame* opener) | 136 void WebFrame::setOpener(WebFrame* opener) |
| 137 { | 137 { |
| 138 if (m_opener) | 138 if (m_opener) |
| 139 m_opener->m_openedFrameTracker->remove(this); | 139 m_opener->m_openedFrameTracker->remove(this); |
| 140 if (opener) | 140 if (opener) |
| 141 opener->m_openedFrameTracker->add(this); | 141 opener->m_openedFrameTracker->add(this); |
| 142 m_opener = opener; | 142 m_opener = opener; |
| 143 } | 143 } |
| 144 | 144 |
| 145 void WebFrame::appendChild(WebFrame* child) | 145 void WebFrame::insertAfter(WebFrame* newChild, WebFrame* previousSibling) |
| 146 { | 146 { |
| 147 // FIXME: Original code asserts that the frames have the same Page. We | 147 newChild->m_parent = this; |
| 148 // should add an equivalent check... figure out what. | |
| 149 child->m_parent = this; | |
| 150 WebFrame* oldLast = m_lastChild; | |
| 151 m_lastChild = child; | |
| 152 | 148 |
| 153 if (oldLast) { | 149 WebFrame* next; |
| 154 child->m_previousSibling = oldLast; | 150 if (!previousSibling) { |
| 155 oldLast->m_nextSibling = child; | 151 // Insert at the beginning if no previous sibling is specified. |
| 152 next = m_firstChild; |
| 153 m_firstChild = newChild; |
| 156 } else { | 154 } else { |
| 157 m_firstChild = child; | 155 ASSERT(previousSibling->m_parent == this); |
| 156 next = previousSibling->m_nextSibling; |
| 157 previousSibling->m_nextSibling = newChild; |
| 158 newChild->m_previousSibling = previousSibling; |
| 159 } |
| 160 |
| 161 if (next) { |
| 162 newChild->m_nextSibling = next; |
| 163 next->m_previousSibling = newChild; |
| 164 } else { |
| 165 m_lastChild = newChild; |
| 158 } | 166 } |
| 159 | 167 |
| 160 toCoreFrame(this)->tree().invalidateScopedChildCount(); | 168 toCoreFrame(this)->tree().invalidateScopedChildCount(); |
| 161 toCoreFrame(this)->host()->incrementSubframeCount(); | 169 toCoreFrame(this)->host()->incrementSubframeCount(); |
| 162 } | 170 } |
| 163 | 171 |
| 172 void WebFrame::appendChild(WebFrame* child) |
| 173 { |
| 174 // TODO(dcheng): Original code asserts that the frames have the same Page. |
| 175 // We should add an equivalent check... figure out what. |
| 176 insertAfter(child, m_lastChild); |
| 177 } |
| 178 |
| 164 void WebFrame::removeChild(WebFrame* child) | 179 void WebFrame::removeChild(WebFrame* child) |
| 165 { | 180 { |
| 166 child->m_parent = 0; | 181 child->m_parent = 0; |
| 167 | 182 |
| 168 if (m_firstChild == child) | 183 if (m_firstChild == child) |
| 169 m_firstChild = child->m_nextSibling; | 184 m_firstChild = child->m_nextSibling; |
| 170 else | 185 else |
| 171 child->m_previousSibling->m_nextSibling = child->m_nextSibling; | 186 child->m_previousSibling->m_nextSibling = child->m_nextSibling; |
| 172 | 187 |
| 173 if (m_lastChild == child) | 188 if (m_lastChild == child) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 bool WebFrame::isFrameAlive(VisitorDispatcher visitor, const WebFrame* frame
) { return isFrameAliveImpl(visitor, frame); } \ | 333 bool WebFrame::isFrameAlive(VisitorDispatcher visitor, const WebFrame* frame
) { return isFrameAliveImpl(visitor, frame); } \ |
| 319 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI
mpl(visitor); } | 334 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { clearWeakFramesI
mpl(visitor); } |
| 320 | 335 |
| 321 DEFINE_VISITOR_METHOD(Visitor*) | 336 DEFINE_VISITOR_METHOD(Visitor*) |
| 322 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) | 337 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) |
| 323 | 338 |
| 324 #undef DEFINE_VISITOR_METHOD | 339 #undef DEFINE_VISITOR_METHOD |
| 325 #endif | 340 #endif |
| 326 | 341 |
| 327 } // namespace blink | 342 } // namespace blink |
| OLD | NEW |