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 "core/frame/RemoteFrame.h" | 8 #include "core/frame/RemoteFrame.h" |
9 #include "core/html/HTMLFrameOwnerElement.h" | 9 #include "core/html/HTMLFrameOwnerElement.h" |
10 #include "web/OpenedFrameTracker.h" | 10 #include "web/OpenedFrameTracker.h" |
11 #include "web/WebLocalFrameImpl.h" | 11 #include "web/WebLocalFrameImpl.h" |
12 #include "web/WebRemoteFrameImpl.h" | 12 #include "web/WebRemoteFrameImpl.h" |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 WebCore::Frame* toWebCoreFrame(const WebFrame* frame) | 18 blink::Frame* toWebCoreFrame(const WebFrame* frame) |
19 { | 19 { |
20 if (!frame) | 20 if (!frame) |
21 return 0; | 21 return 0; |
22 | 22 |
23 return frame->isWebLocalFrame() | 23 return frame->isWebLocalFrame() |
24 ? static_cast<WebCore::Frame*>(toWebLocalFrameImpl(frame)->frame()) | 24 ? static_cast<blink::Frame*>(toWebLocalFrameImpl(frame)->frame()) |
25 : toWebRemoteFrameImpl(frame)->frame(); | 25 : toWebRemoteFrameImpl(frame)->frame(); |
26 } | 26 } |
27 | 27 |
28 void WebFrame::swap(WebFrame* frame) | 28 void WebFrame::swap(WebFrame* frame) |
29 { | 29 { |
30 using std::swap; | 30 using std::swap; |
31 | 31 |
32 // All child frames must have been detached first. | 32 // All child frames must have been detached first. |
33 ASSERT(!m_firstChild && !m_lastChild); | 33 ASSERT(!m_firstChild && !m_lastChild); |
34 // The frame being swapped in should not have a WebCore::Frame associated | 34 // The frame being swapped in should not have a blink::Frame associated |
35 // with it yet. | 35 // with it yet. |
36 ASSERT(!toWebCoreFrame(frame)); | 36 ASSERT(!toWebCoreFrame(frame)); |
37 | 37 |
38 if (m_parent) { | 38 if (m_parent) { |
39 if (m_parent->m_firstChild == this) | 39 if (m_parent->m_firstChild == this) |
40 m_parent->m_firstChild = frame; | 40 m_parent->m_firstChild = frame; |
41 if (m_parent->m_lastChild == this) | 41 if (m_parent->m_lastChild == this) |
42 m_parent->m_lastChild = frame; | 42 m_parent->m_lastChild = frame; |
43 swap(m_parent, frame->m_parent); | 43 swap(m_parent, frame->m_parent); |
44 } | 44 } |
(...skipping 10 matching lines...) Expand all Loading... |
55 if (m_opener) { | 55 if (m_opener) { |
56 m_opener->m_openedFrameTracker->remove(this); | 56 m_opener->m_openedFrameTracker->remove(this); |
57 m_opener->m_openedFrameTracker->add(frame); | 57 m_opener->m_openedFrameTracker->add(frame); |
58 swap(m_opener, frame->m_opener); | 58 swap(m_opener, frame->m_opener); |
59 } | 59 } |
60 if (!m_openedFrameTracker->isEmpty()) { | 60 if (!m_openedFrameTracker->isEmpty()) { |
61 m_openedFrameTracker->updateOpener(frame); | 61 m_openedFrameTracker->updateOpener(frame); |
62 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); | 62 frame->m_openedFrameTracker.reset(m_openedFrameTracker.release()); |
63 } | 63 } |
64 | 64 |
65 // Finally, clone the state of the current WebCore::Frame into one matching | 65 // Finally, clone the state of the current blink::Frame into one matching |
66 // the type of the passed in WebFrame. | 66 // the type of the passed in WebFrame. |
67 // FIXME: This is a bit clunky; this results in pointless decrements and | 67 // FIXME: This is a bit clunky; this results in pointless decrements and |
68 // increments of connected subframes. | 68 // increments of connected subframes. |
69 WebCore::Frame* oldFrame = toWebCoreFrame(this); | 69 blink::Frame* oldFrame = toWebCoreFrame(this); |
70 WebCore::FrameOwner* owner = oldFrame->owner(); | 70 blink::FrameOwner* owner = oldFrame->owner(); |
71 oldFrame->disconnectOwnerElement(); | 71 oldFrame->disconnectOwnerElement(); |
72 if (frame->isWebLocalFrame()) { | 72 if (frame->isWebLocalFrame()) { |
73 toWebLocalFrameImpl(frame)->initializeWebCoreFrame(oldFrame->host(), own
er, oldFrame->tree().name(), nullAtom); | 73 toWebLocalFrameImpl(frame)->initializeWebCoreFrame(oldFrame->host(), own
er, oldFrame->tree().name(), nullAtom); |
74 } else { | 74 } else { |
75 toWebRemoteFrameImpl(frame)->initializeWebCoreFrame(oldFrame->host(), ow
ner, oldFrame->tree().name()); | 75 toWebRemoteFrameImpl(frame)->initializeWebCoreFrame(oldFrame->host(), ow
ner, oldFrame->tree().name()); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 WebFrame* WebFrame::opener() const | 79 WebFrame* WebFrame::opener() const |
80 { | 80 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return m_previousSibling; | 155 return m_previousSibling; |
156 } | 156 } |
157 | 157 |
158 WebFrame* WebFrame::nextSibling() const | 158 WebFrame* WebFrame::nextSibling() const |
159 { | 159 { |
160 return m_nextSibling; | 160 return m_nextSibling; |
161 } | 161 } |
162 | 162 |
163 WebFrame* WebFrame::traversePrevious(bool wrap) const | 163 WebFrame* WebFrame::traversePrevious(bool wrap) const |
164 { | 164 { |
165 WebCore::Frame* frame = toWebCoreFrame(this); | 165 blink::Frame* frame = toWebCoreFrame(this); |
166 if (!frame) | 166 if (!frame) |
167 return 0; | 167 return 0; |
168 return fromFrame(frame->tree().traversePreviousWithWrap(wrap)); | 168 return fromFrame(frame->tree().traversePreviousWithWrap(wrap)); |
169 } | 169 } |
170 | 170 |
171 WebFrame* WebFrame::traverseNext(bool wrap) const | 171 WebFrame* WebFrame::traverseNext(bool wrap) const |
172 { | 172 { |
173 WebCore::Frame* frame = toWebCoreFrame(this); | 173 blink::Frame* frame = toWebCoreFrame(this); |
174 if (!frame) | 174 if (!frame) |
175 return 0; | 175 return 0; |
176 return fromFrame(frame->tree().traverseNextWithWrap(wrap)); | 176 return fromFrame(frame->tree().traverseNextWithWrap(wrap)); |
177 } | 177 } |
178 | 178 |
179 WebFrame* WebFrame::findChildByName(const WebString& name) const | 179 WebFrame* WebFrame::findChildByName(const WebString& name) const |
180 { | 180 { |
181 WebCore::Frame* frame = toWebCoreFrame(this); | 181 blink::Frame* frame = toWebCoreFrame(this); |
182 if (!frame) | 182 if (!frame) |
183 return 0; | 183 return 0; |
184 // FIXME: It's not clear this should ever be called to find a remote frame. | 184 // FIXME: It's not clear this should ever be called to find a remote frame. |
185 // Perhaps just disallow that completely? | 185 // Perhaps just disallow that completely? |
186 return fromFrame(frame->tree().child(name)); | 186 return fromFrame(frame->tree().child(name)); |
187 } | 187 } |
188 | 188 |
189 WebFrame* WebFrame::fromFrame(WebCore::Frame* frame) | 189 WebFrame* WebFrame::fromFrame(blink::Frame* frame) |
190 { | 190 { |
191 if (!frame) | 191 if (!frame) |
192 return 0; | 192 return 0; |
193 | 193 |
194 if (frame->isLocalFrame()) | 194 if (frame->isLocalFrame()) |
195 return WebLocalFrameImpl::fromFrame(toLocalFrame(*frame)); | 195 return WebLocalFrameImpl::fromFrame(toLocalFrame(*frame)); |
196 return WebRemoteFrameImpl::fromFrame(toRemoteFrame(*frame)); | 196 return WebRemoteFrameImpl::fromFrame(toRemoteFrame(*frame)); |
197 } | 197 } |
198 | 198 |
199 WebFrame::WebFrame() | 199 WebFrame::WebFrame() |
200 : m_parent(0) | 200 : m_parent(0) |
201 , m_previousSibling(0) | 201 , m_previousSibling(0) |
202 , m_nextSibling(0) | 202 , m_nextSibling(0) |
203 , m_firstChild(0) | 203 , m_firstChild(0) |
204 , m_lastChild(0) | 204 , m_lastChild(0) |
205 , m_opener(0) | 205 , m_opener(0) |
206 , m_openedFrameTracker(new OpenedFrameTracker) | 206 , m_openedFrameTracker(new OpenedFrameTracker) |
207 { | 207 { |
208 } | 208 } |
209 | 209 |
210 WebFrame::~WebFrame() | 210 WebFrame::~WebFrame() |
211 { | 211 { |
212 m_openedFrameTracker.reset(0); | 212 m_openedFrameTracker.reset(0); |
213 } | 213 } |
214 | 214 |
215 } // namespace blink | 215 } // namespace blink |
OLD | NEW |