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

Side by Side Diff: Source/core/html/HTMLFrameOwnerElement.cpp

Issue 23618022: BrowserPlugin/WebView - Move plugin lifetime to DOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Handle shared-renderer case. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLFrameOwnerElement.h ('k') | Source/core/html/HTMLObjectElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8/ExceptionMessages.h" 24 #include "bindings/v8/ExceptionMessages.h"
25 #include "bindings/v8/ExceptionState.h" 25 #include "bindings/v8/ExceptionState.h"
26 #include "core/accessibility/AXObjectCache.h"
26 #include "core/dom/ExceptionCode.h" 27 #include "core/dom/ExceptionCode.h"
27 #include "core/frame/FrameView.h" 28 #include "core/frame/FrameView.h"
28 #include "core/frame/LocalFrame.h" 29 #include "core/frame/LocalFrame.h"
29 #include "core/loader/FrameLoader.h" 30 #include "core/loader/FrameLoader.h"
30 #include "core/loader/FrameLoaderClient.h" 31 #include "core/loader/FrameLoaderClient.h"
32 #include "core/rendering/RenderLayer.h"
31 #include "core/rendering/RenderPart.h" 33 #include "core/rendering/RenderPart.h"
34 #include "core/rendering/compositing/RenderLayerCompositor.h"
32 #include "core/svg/SVGDocument.h" 35 #include "core/svg/SVGDocument.h"
33 #include "platform/weborigin/SecurityOrigin.h" 36 #include "platform/weborigin/SecurityOrigin.h"
34 #include "platform/weborigin/SecurityPolicy.h" 37 #include "platform/weborigin/SecurityPolicy.h"
35 38
36 namespace WebCore { 39 namespace WebCore {
37 40
41 typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap;
42 static WidgetToParentMap& widgetNewParentMap()
43 {
44 DEFINE_STATIC_LOCAL(WidgetToParentMap, map, ());
45 return map;
46 }
47
48 static unsigned s_updateSuspendCount = 0;
49
50 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope()
51 {
52 ++s_updateSuspendCount;
53 }
54
55 void HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOperati ons()
56 {
57 WidgetToParentMap map;
58 widgetNewParentMap().swap(map);
59 WidgetToParentMap::iterator end = map.end();
60 for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) {
61 Widget* child = it->key.get();
62 ScrollView* currentParent = toScrollView(child->parent());
63 FrameView* newParent = it->value;
64 if (newParent != currentParent) {
65 if (currentParent)
66 currentParent->removeChild(child);
67 if (newParent)
68 newParent->addChild(child);
69 }
70 }
71 }
72
73 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope()
74 {
75 ASSERT(s_updateSuspendCount > 0);
76 if (s_updateSuspendCount == 1)
77 performDeferredWidgetTreeOperations();
78 --s_updateSuspendCount;
79 }
80
81 static void moveWidgetToParentSoon(Widget* child, FrameView* parent)
82 {
83 if (!s_updateSuspendCount) {
84 if (parent)
85 parent->addChild(child);
86 else if (toScrollView(child->parent()))
87 toScrollView(child->parent())->removeChild(child);
88 return;
89 }
90 widgetNewParentMap().set(child, parent);
91 }
92
38 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum ent& document) 93 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum ent& document)
39 : HTMLElement(tagName, document) 94 : HTMLElement(tagName, document)
40 , m_contentFrame(0) 95 , m_contentFrame(0)
96 , m_widget(nullptr)
41 , m_sandboxFlags(SandboxNone) 97 , m_sandboxFlags(SandboxNone)
42 { 98 {
43 } 99 }
44 100
45 RenderPart* HTMLFrameOwnerElement::renderPart() const 101 RenderPart* HTMLFrameOwnerElement::renderPart() const
46 { 102 {
47 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers 103 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
48 // when using fallback content. 104 // when using fallback content.
49 if (!renderer() || !renderer()->isRenderPart()) 105 if (!renderer() || !renderer()->isRenderPart())
50 return 0; 106 return 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 171 }
116 172
117 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionState& exceptionStat e) const 173 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionState& exceptionStat e) const
118 { 174 {
119 Document* doc = contentDocument(); 175 Document* doc = contentDocument();
120 if (doc && doc->isSVGDocument()) 176 if (doc && doc->isSVGDocument())
121 return toSVGDocument(doc); 177 return toSVGDocument(doc);
122 return 0; 178 return 0;
123 } 179 }
124 180
181 void HTMLFrameOwnerElement::setWidget(PassRefPtr<Widget> widget)
182 {
183 if (widget == m_widget)
184 return;
185
186 if (m_widget) {
187 if (m_widget->parent())
188 moveWidgetToParentSoon(m_widget.get(), 0);
189 m_widget = nullptr;
190 }
191
192 m_widget = widget;
193
194 RenderWidget* renderWidget = toRenderWidget(renderer());
195 if (!renderWidget)
196 return;
197
198 if (m_widget) {
199 renderWidget->updateOnWidgetChange();
200
201 ASSERT(document().view() == renderWidget->frameView());
202 ASSERT(renderWidget->frameView());
203 moveWidgetToParentSoon(m_widget.get(), renderWidget->frameView());
204 }
205
206 if (AXObjectCache* cache = document().existingAXObjectCache())
207 cache->childrenChanged(renderWidget);
208 }
209
210 Widget* HTMLFrameOwnerElement::ownedWidget() const
211 {
212 return m_widget.get();
213 }
214
125 bool HTMLFrameOwnerElement::loadOrRedirectSubframe(const KURL& url, const Atomic String& frameName, bool lockBackForwardList) 215 bool HTMLFrameOwnerElement::loadOrRedirectSubframe(const KURL& url, const Atomic String& frameName, bool lockBackForwardList)
126 { 216 {
127 RefPtr<LocalFrame> parentFrame = document().frame(); 217 RefPtr<LocalFrame> parentFrame = document().frame();
128 // FIXME(kenrb): The necessary semantics for RemoteFrames have not been work ed out yet, but this will likely need some logic to handle them. 218 // FIXME(kenrb): The necessary semantics for RemoteFrames have not been work ed out yet, but this will likely need some logic to handle them.
129 if (contentFrame() && contentFrame()->isLocalFrame()) { 219 if (contentFrame() && contentFrame()->isLocalFrame()) {
130 toLocalFrame(contentFrame())->navigationScheduler().scheduleLocationChan ge(&document(), url.string(), Referrer(document().outgoingReferrer(), document() .referrerPolicy()), lockBackForwardList); 220 toLocalFrame(contentFrame())->navigationScheduler().scheduleLocationChan ge(&document(), url.string(), Referrer(document().outgoingReferrer(), document() .referrerPolicy()), lockBackForwardList);
131 return true; 221 return true;
132 } 222 }
133 223
134 if (!document().securityOrigin()->canDisplay(url)) { 224 if (!document().securityOrigin()->canDisplay(url)) {
(...skipping 13 matching lines...) Expand all
148 } 238 }
149 239
150 // All new frames will have m_isComplete set to true at this point due to sy nchronously loading 240 // All new frames will have m_isComplete set to true at this point due to sy nchronously loading
151 // an empty document in FrameLoader::init(). But many frames will now be sta rting an 241 // an empty document in FrameLoader::init(). But many frames will now be sta rting an
152 // asynchronous load of url, so we set m_isComplete to false and then check if the load is 242 // asynchronous load of url, so we set m_isComplete to false and then check if the load is
153 // actually completed below. (Note that we set m_isComplete to false even fo r synchronous 243 // actually completed below. (Note that we set m_isComplete to false even fo r synchronous
154 // loads, so that checkCompleted() below won't bail early.) 244 // loads, so that checkCompleted() below won't bail early.)
155 // FIXME: Can we remove this entirely? m_isComplete normally gets set to fal se when a load is committed. 245 // FIXME: Can we remove this entirely? m_isComplete normally gets set to fal se when a load is committed.
156 childFrame->loader().started(); 246 childFrame->loader().started();
157 247
248 FrameView* view = childFrame->view();
158 RenderObject* renderObject = renderer(); 249 RenderObject* renderObject = renderer();
159 FrameView* view = childFrame->view(); 250 // We need to test the existence of renderObject and its widget-ness, as
251 // failing to do so causes problems.
160 if (renderObject && renderObject->isWidget() && view) 252 if (renderObject && renderObject->isWidget() && view)
161 toRenderWidget(renderObject)->setWidget(view); 253 setWidget(view);
162 254
163 // Some loads are performed synchronously (e.g., about:blank and loads 255 // Some loads are performed synchronously (e.g., about:blank and loads
164 // cancelled by returning a null ResourceRequest from requestFromDelegate). 256 // cancelled by returning a null ResourceRequest from requestFromDelegate).
165 // In these cases, the synchronous load would have finished 257 // In these cases, the synchronous load would have finished
166 // before we could connect the signals, so make sure to send the 258 // before we could connect the signals, so make sure to send the
167 // completed() signal for the child by hand and mark the load as being 259 // completed() signal for the child by hand and mark the load as being
168 // complete. 260 // complete.
169 // FIXME: In this case the LocalFrame will have finished loading before 261 // FIXME: In this case the LocalFrame will have finished loading before
170 // it's being added to the child list. It would be a good idea to 262 // it's being added to the child list. It would be a good idea to
171 // create the child first, then invoke the loader separately. 263 // create the child first, then invoke the loader separately.
172 if (childFrame->loader().state() == FrameStateComplete && !childFrame->loade r().policyDocumentLoader()) 264 if (childFrame->loader().state() == FrameStateComplete && !childFrame->loade r().policyDocumentLoader())
173 childFrame->loader().checkCompleted(); 265 childFrame->loader().checkCompleted();
174 return true; 266 return true;
175 } 267 }
176 268
177 269
178 } // namespace WebCore 270 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFrameOwnerElement.h ('k') | Source/core/html/HTMLObjectElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698