OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 * | 18 * |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 #include "core/html/HTMLFrameOwnerElement.h" | 22 #include "core/html/HTMLFrameOwnerElement.h" |
23 | 23 |
24 #include "bindings/core/v8/ExceptionMessages.h" | 24 #include "bindings/core/v8/ExceptionMessages.h" |
25 #include "bindings/core/v8/ExceptionState.h" | 25 #include "bindings/core/v8/ExceptionState.h" |
26 #include "core/accessibility/AXObjectCache.h" | 26 #include "core/accessibility/AXObjectCache.h" |
27 #include "core/dom/ExceptionCode.h" | 27 #include "core/dom/ExceptionCode.h" |
28 #include "core/events/Event.h" | 28 #include "core/events/Event.h" |
| 29 #include "core/frame/FrameProtector.h" |
29 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
30 #include "core/frame/LocalFrame.h" | 31 #include "core/frame/LocalFrame.h" |
31 #include "core/loader/FrameLoader.h" | 32 #include "core/loader/FrameLoader.h" |
32 #include "core/loader/FrameLoaderClient.h" | 33 #include "core/loader/FrameLoaderClient.h" |
33 #include "core/rendering/RenderLayer.h" | 34 #include "core/rendering/RenderLayer.h" |
34 #include "core/rendering/RenderPart.h" | 35 #include "core/rendering/RenderPart.h" |
35 #include "core/rendering/compositing/RenderLayerCompositor.h" | 36 #include "core/rendering/compositing/RenderLayerCompositor.h" |
36 #include "platform/weborigin/SecurityOrigin.h" | 37 #include "platform/weborigin/SecurityOrigin.h" |
37 #include "platform/weborigin/SecurityPolicy.h" | 38 #include "platform/weborigin/SecurityPolicy.h" |
38 | 39 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 parent->addChild(child); | 92 parent->addChild(child); |
92 else if (toScrollView(child->parent())) | 93 else if (toScrollView(child->parent())) |
93 toScrollView(child->parent())->removeChild(child); | 94 toScrollView(child->parent())->removeChild(child); |
94 return; | 95 return; |
95 } | 96 } |
96 widgetNewParentMap().set(child, parent); | 97 widgetNewParentMap().set(child, parent); |
97 } | 98 } |
98 | 99 |
99 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum
ent& document) | 100 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum
ent& document) |
100 : HTMLElement(tagName, document) | 101 : HTMLElement(tagName, document) |
101 , m_contentFrame(0) | 102 , m_contentFrame(nullptr) |
102 , m_widget(nullptr) | 103 , m_widget(nullptr) |
103 , m_sandboxFlags(SandboxNone) | 104 , m_sandboxFlags(SandboxNone) |
104 { | 105 { |
105 } | 106 } |
106 | 107 |
107 RenderPart* HTMLFrameOwnerElement::renderPart() const | 108 RenderPart* HTMLFrameOwnerElement::renderPart() const |
108 { | 109 { |
109 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers | 110 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers |
110 // when using fallback content. | 111 // when using fallback content. |
111 if (!renderer() || !renderer()->isRenderPart()) | 112 if (!renderer() || !renderer()->isRenderPart()) |
(...skipping 11 matching lines...) Expand all Loading... |
123 | 124 |
124 for (ContainerNode* node = this; node; node = node->parentOrShadowHostNode()
) | 125 for (ContainerNode* node = this; node; node = node->parentOrShadowHostNode()
) |
125 node->incrementConnectedSubframeCount(); | 126 node->incrementConnectedSubframeCount(); |
126 } | 127 } |
127 | 128 |
128 void HTMLFrameOwnerElement::clearContentFrame() | 129 void HTMLFrameOwnerElement::clearContentFrame() |
129 { | 130 { |
130 if (!m_contentFrame) | 131 if (!m_contentFrame) |
131 return; | 132 return; |
132 | 133 |
133 m_contentFrame = 0; | 134 m_contentFrame = nullptr; |
134 | 135 |
135 for (ContainerNode* node = this; node; node = node->parentOrShadowHostNode()
) | 136 for (ContainerNode* node = this; node; node = node->parentOrShadowHostNode()
) |
136 node->decrementConnectedSubframeCount(); | 137 node->decrementConnectedSubframeCount(); |
137 } | 138 } |
138 | 139 |
139 void HTMLFrameOwnerElement::disconnectContentFrame() | 140 void HTMLFrameOwnerElement::disconnectContentFrame() |
140 { | 141 { |
141 // FIXME: Currently we don't do this in removedFrom because this causes an | 142 // FIXME: Currently we don't do this in removedFrom because this causes an |
142 // unload event in the subframe which could execute script that could then | 143 // unload event in the subframe which could execute script that could then |
143 // reach up into this document and then attempt to look back down. We should | 144 // reach up into this document and then attempt to look back down. We should |
144 // see if this behavior is really needed as Gecko does not allow this. | 145 // see if this behavior is really needed as Gecko does not allow this. |
145 if (Frame* frame = contentFrame()) { | 146 if (Frame* frame = contentFrame()) { |
146 RefPtr<Frame> protect(frame); | 147 FrameProtector protect(frame); |
147 frame->detach(); | 148 frame->detach(); |
148 frame->disconnectOwnerElement(); | 149 frame->disconnectOwnerElement(); |
149 } | 150 } |
150 } | 151 } |
151 | 152 |
152 HTMLFrameOwnerElement::~HTMLFrameOwnerElement() | 153 HTMLFrameOwnerElement::~HTMLFrameOwnerElement() |
153 { | 154 { |
| 155 #if ENABLE(OILPAN) |
| 156 // An owner must by now have been informed of detachment |
| 157 // when the frame was closed. |
| 158 ASSERT(!m_contentFrame); |
| 159 #else |
154 if (m_contentFrame) | 160 if (m_contentFrame) |
155 m_contentFrame->disconnectOwnerElement(); | 161 m_contentFrame->disconnectOwnerElement(); |
| 162 #endif |
156 } | 163 } |
157 | 164 |
158 Document* HTMLFrameOwnerElement::contentDocument() const | 165 Document* HTMLFrameOwnerElement::contentDocument() const |
159 { | 166 { |
160 return (m_contentFrame && m_contentFrame->isLocalFrame()) ? toLocalFrame(m_c
ontentFrame)->document() : 0; | 167 return (m_contentFrame && m_contentFrame->isLocalFrame()) ? toLocalFrame(m_c
ontentFrame)->document() : 0; |
161 } | 168 } |
162 | 169 |
163 LocalDOMWindow* HTMLFrameOwnerElement::contentWindow() const | 170 LocalDOMWindow* HTMLFrameOwnerElement::contentWindow() const |
164 { | 171 { |
165 return m_contentFrame ? m_contentFrame->domWindow() : 0; | 172 return m_contentFrame ? m_contentFrame->domWindow() : 0; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 cache->childrenChanged(renderWidget); | 224 cache->childrenChanged(renderWidget); |
218 } | 225 } |
219 | 226 |
220 Widget* HTMLFrameOwnerElement::ownedWidget() const | 227 Widget* HTMLFrameOwnerElement::ownedWidget() const |
221 { | 228 { |
222 return m_widget.get(); | 229 return m_widget.get(); |
223 } | 230 } |
224 | 231 |
225 bool HTMLFrameOwnerElement::loadOrRedirectSubframe(const KURL& url, const Atomic
String& frameName, bool lockBackForwardList) | 232 bool HTMLFrameOwnerElement::loadOrRedirectSubframe(const KURL& url, const Atomic
String& frameName, bool lockBackForwardList) |
226 { | 233 { |
227 RefPtr<LocalFrame> parentFrame = document().frame(); | 234 LocalFrame* parentFrame = document().frame(); |
| 235 FrameProtector protect(parentFrame); |
228 // FIXME(kenrb): The necessary semantics for RemoteFrames have not been work
ed out yet, but this will likely need some logic to handle them. | 236 // FIXME(kenrb): The necessary semantics for RemoteFrames have not been work
ed out yet, but this will likely need some logic to handle them. |
229 if (contentFrame() && contentFrame()->isLocalFrame()) { | 237 if (contentFrame() && contentFrame()->isLocalFrame()) { |
230 toLocalFrame(contentFrame())->navigationScheduler().scheduleLocationChan
ge(&document(), url.string(), Referrer(document().outgoingReferrer(), document()
.referrerPolicy()), lockBackForwardList); | 238 toLocalFrame(contentFrame())->navigationScheduler().scheduleLocationChan
ge(&document(), url.string(), Referrer(document().outgoingReferrer(), document()
.referrerPolicy()), lockBackForwardList); |
231 return true; | 239 return true; |
232 } | 240 } |
233 | 241 |
234 if (!document().securityOrigin()->canDisplay(url)) { | 242 if (!document().securityOrigin()->canDisplay(url)) { |
235 FrameLoader::reportLocalLoadFailed(parentFrame.get(), url.string()); | 243 FrameLoader::reportLocalLoadFailed(parentFrame, url.string()); |
236 return false; | 244 return false; |
237 } | 245 } |
238 | 246 |
239 if (!SubframeLoadingDisabler::canLoadFrame(*this)) | 247 if (!SubframeLoadingDisabler::canLoadFrame(*this)) |
240 return false; | 248 return false; |
241 | 249 |
242 String referrer = SecurityPolicy::generateReferrerHeader(document().referrer
Policy(), url, document().outgoingReferrer()); | 250 String referrer = SecurityPolicy::generateReferrerHeader(document().referrer
Policy(), url, document().outgoingReferrer()); |
243 return parentFrame->loader().client()->createFrame(url, frameName, Referrer(
referrer, document().referrerPolicy()), this); | 251 return parentFrame->loader().client()->createFrame(url, frameName, Referrer(
referrer, document().referrerPolicy()), this); |
244 } | 252 } |
245 | 253 |
| 254 void HTMLFrameOwnerElement::trace(Visitor* visitor) |
| 255 { |
| 256 visitor->trace(m_contentFrame); |
| 257 HTMLElement::trace(visitor); |
| 258 FrameOwner::trace(visitor); |
| 259 } |
| 260 |
246 | 261 |
247 } // namespace blink | 262 } // namespace blink |
OLD | NEW |