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

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

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add ~Scrollbar assert Created 6 years, 2 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
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
(...skipping 12 matching lines...) Expand all
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/FrameView.h" 29 #include "core/frame/FrameView.h"
30 #include "core/frame/LocalFrame.h" 30 #include "core/frame/LocalFrame.h"
31 #include "core/loader/FrameLoader.h" 31 #include "core/loader/FrameLoader.h"
32 #include "core/loader/FrameLoaderClient.h" 32 #include "core/loader/FrameLoaderClient.h"
33 #include "core/plugins/PluginView.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
39 namespace blink { 40 namespace blink {
40 41
41 typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap; 42 typedef WillBeHeapHashMap<RefPtrWillBeMember<Widget>, RawPtrWillBeMember<FrameVi ew> > WidgetToParentMap;
42 static WidgetToParentMap& widgetNewParentMap() 43 static WidgetToParentMap& widgetNewParentMap()
43 { 44 {
44 DEFINE_STATIC_LOCAL(WidgetToParentMap, map, ()); 45 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WidgetToParentMap>, map, (adoptPt rWillBeNoop(new WidgetToParentMap())));
45 return map; 46 return *map;
46 } 47 }
47 48
48 WillBeHeapHashCountedSet<RawPtrWillBeMember<Node> >& SubframeLoadingDisabler::di sabledSubtreeRoots() 49 WillBeHeapHashCountedSet<RawPtrWillBeMember<Node> >& SubframeLoadingDisabler::di sabledSubtreeRoots()
49 { 50 {
50 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashCountedSet<RawPtrWi llBeMember<Node> > >, nodes, (adoptPtrWillBeNoop(new WillBeHeapHashCountedSet<Ra wPtrWillBeMember<Node> >()))); 51 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashCountedSet<RawPtrWi llBeMember<Node> > >, nodes, (adoptPtrWillBeNoop(new WillBeHeapHashCountedSet<Ra wPtrWillBeMember<Node> >())));
51 return *nodes; 52 return *nodes;
52 } 53 }
53 54
54 static unsigned s_updateSuspendCount = 0; 55 static unsigned s_updateSuspendCount = 0;
55 56
56 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope() 57 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope()
57 { 58 {
58 ++s_updateSuspendCount; 59 ++s_updateSuspendCount;
59 } 60 }
60 61
61 void HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOperati ons() 62 void HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOperati ons()
62 { 63 {
63 WidgetToParentMap map; 64 WidgetToParentMap map;
64 widgetNewParentMap().swap(map); 65 widgetNewParentMap().swap(map);
65 WidgetToParentMap::iterator end = map.end(); 66 WidgetToParentMap::iterator end = map.end();
66 for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) { 67 for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) {
67 Widget* child = it->key.get(); 68 Widget* child = it->key.get();
68 ScrollView* currentParent = toScrollView(child->parent()); 69 ScrollView* currentParent = toScrollView(child->parent());
69 FrameView* newParent = it->value; 70 FrameView* newParent = it->value;
70 if (newParent != currentParent) { 71 if (newParent != currentParent) {
71 if (currentParent) 72 if (currentParent)
72 currentParent->removeChild(child); 73 currentParent->removeChild(child);
73 if (newParent) 74 if (newParent)
74 newParent->addChild(child); 75 newParent->addChild(child);
76 #if ENABLE(OILPAN)
77 if (currentParent && !newParent)
78 HTMLFrameOwnerElement::disposeWidget(child);
79 #endif
75 } 80 }
76 } 81 }
77 } 82 }
78 83
79 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope() 84 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope()
80 { 85 {
81 ASSERT(s_updateSuspendCount > 0); 86 ASSERT(s_updateSuspendCount > 0);
82 if (s_updateSuspendCount == 1) 87 if (s_updateSuspendCount == 1)
83 performDeferredWidgetTreeOperations(); 88 performDeferredWidgetTreeOperations();
84 --s_updateSuspendCount; 89 --s_updateSuspendCount;
85 } 90 }
86 91
87 static void moveWidgetToParentSoon(Widget* child, FrameView* parent) 92 static void moveWidgetToParentSoon(Widget* child, FrameView* parent)
88 { 93 {
89 if (!s_updateSuspendCount) { 94 if (!s_updateSuspendCount) {
90 if (parent) 95 if (parent) {
91 parent->addChild(child); 96 parent->addChild(child);
92 else if (toScrollView(child->parent())) 97 } else if (toScrollView(child->parent())) {
93 toScrollView(child->parent())->removeChild(child); 98 toScrollView(child->parent())->removeChild(child);
99 #if ENABLE(OILPAN)
100 HTMLFrameOwnerElement::disposeWidget(child);
101 #endif
102 }
94 return; 103 return;
95 } 104 }
96 widgetNewParentMap().set(child, parent); 105 widgetNewParentMap().set(child, parent);
97 } 106 }
98 107
99 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum ent& document) 108 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum ent& document)
100 : HTMLElement(tagName, document) 109 : HTMLElement(tagName, document)
101 , m_contentFrame(nullptr) 110 , m_contentFrame(nullptr)
102 , m_widget(nullptr) 111 , m_widget(nullptr)
103 , m_sandboxFlags(SandboxNone) 112 , m_sandboxFlags(SandboxNone)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 146 }
138 147
139 void HTMLFrameOwnerElement::disconnectContentFrame() 148 void HTMLFrameOwnerElement::disconnectContentFrame()
140 { 149 {
141 // FIXME: Currently we don't do this in removedFrom because this causes an 150 // 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 151 // 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 152 // 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. 153 // see if this behavior is really needed as Gecko does not allow this.
145 if (RefPtrWillBeRawPtr<Frame> frame = contentFrame()) { 154 if (RefPtrWillBeRawPtr<Frame> frame = contentFrame()) {
146 frame->detach(); 155 frame->detach();
147 #if ENABLE(OILPAN)
148 // FIXME: Oilpan: the plugin container is released and finalized here
149 // in order to work around the current inability to make the plugin
150 // container a FrameDestructionObserver (it needs to effectively be on
151 // the heap, and Widget isn't). Hence, release it here while its
152 // frame reference is still valid.
153 if (m_widget && m_widget->isPluginContainer())
154 m_widget = nullptr;
155 #endif
156 frame->disconnectOwnerElement(); 156 frame->disconnectOwnerElement();
157 } 157 }
158 #if ENABLE(OILPAN)
159 disposeWidget(m_widget.get());
160 m_widget = nullptr;
161 #endif
158 } 162 }
159 163
160 HTMLFrameOwnerElement::~HTMLFrameOwnerElement() 164 HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
161 { 165 {
162 #if ENABLE(OILPAN) 166 #if ENABLE(OILPAN)
163 // An owner must by now have been informed of detachment 167 // An owner must by now have been informed of detachment
164 // when the frame was closed. 168 // when the frame was closed.
165 ASSERT(!m_contentFrame); 169 ASSERT(!m_contentFrame);
166 #else 170 #else
167 if (m_contentFrame) 171 if (m_contentFrame)
168 m_contentFrame->disconnectOwnerElement(); 172 m_contentFrame->disconnectOwnerElement();
169 #endif 173 #endif
170 } 174 }
171 175
176 #if ENABLE(OILPAN)
177 void HTMLFrameOwnerElement::disposeWidget(Widget* widget)
haraken 2014/09/29 14:16:36 Can we avoid adding this static method by defining
sof 2014/10/07 11:03:36 ok, let's do that instead (as we've reduced our 'v
178 {
179 // Oilpan: a plugin container must be disposed of prior to (GC)
haraken 2014/09/29 14:16:36 I don't fully understand this well, but what happe
sof 2014/10/07 11:03:36 This suggestion doesn't seem to address what the c
180 // finalization of it and all it depends on. Needed to ensure that
181 // the underlying plugin is able to access a fully-functioning
182 // frame while it destructs.
183 if (widget && widget->isPluginView())
haraken 2014/09/29 14:16:36 Is it possible that this method is called with a n
sof 2014/10/07 11:03:36 As it is currently used, yes.
184 toPluginView(widget)->dispose();
185 }
186 #endif
187
172 Document* HTMLFrameOwnerElement::contentDocument() const 188 Document* HTMLFrameOwnerElement::contentDocument() const
173 { 189 {
174 return (m_contentFrame && m_contentFrame->isLocalFrame()) ? toLocalFrame(m_c ontentFrame)->document() : 0; 190 return (m_contentFrame && m_contentFrame->isLocalFrame()) ? toLocalFrame(m_c ontentFrame)->document() : 0;
175 } 191 }
176 192
177 LocalDOMWindow* HTMLFrameOwnerElement::contentWindow() const 193 LocalDOMWindow* HTMLFrameOwnerElement::contentWindow() const
178 { 194 {
179 return m_contentFrame ? m_contentFrame->domWindow() : 0; 195 return m_contentFrame ? m_contentFrame->domWindow() : 0;
180 } 196 }
181 197
(...skipping 13 matching lines...) Expand all
195 } 211 }
196 212
197 Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionState& exceptionState) const 213 Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionState& exceptionState) const
198 { 214 {
199 Document* doc = contentDocument(); 215 Document* doc = contentDocument();
200 if (doc && doc->isSVGDocument()) 216 if (doc && doc->isSVGDocument())
201 return doc; 217 return doc;
202 return 0; 218 return 0;
203 } 219 }
204 220
205 void HTMLFrameOwnerElement::setWidget(PassRefPtr<Widget> widget) 221 void HTMLFrameOwnerElement::setWidget(PassRefPtrWillBeRawPtr<Widget> widget)
206 { 222 {
207 if (widget == m_widget) 223 if (widget == m_widget)
208 return; 224 return;
209 225
210 if (m_widget) { 226 if (m_widget) {
211 if (m_widget->parent()) 227 if (m_widget->parent())
212 moveWidgetToParentSoon(m_widget.get(), 0); 228 moveWidgetToParentSoon(m_widget.get(), 0);
213 m_widget = nullptr; 229 m_widget = nullptr;
214 } 230 }
215 231
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (!SubframeLoadingDisabler::canLoadFrame(*this)) 268 if (!SubframeLoadingDisabler::canLoadFrame(*this))
253 return false; 269 return false;
254 270
255 String referrer = SecurityPolicy::generateReferrerHeader(document().referrer Policy(), url, document().outgoingReferrer()); 271 String referrer = SecurityPolicy::generateReferrerHeader(document().referrer Policy(), url, document().outgoingReferrer());
256 return parentFrame->loader().client()->createFrame(url, frameName, Referrer( referrer, document().referrerPolicy()), this); 272 return parentFrame->loader().client()->createFrame(url, frameName, Referrer( referrer, document().referrerPolicy()), this);
257 } 273 }
258 274
259 void HTMLFrameOwnerElement::trace(Visitor* visitor) 275 void HTMLFrameOwnerElement::trace(Visitor* visitor)
260 { 276 {
261 visitor->trace(m_contentFrame); 277 visitor->trace(m_contentFrame);
278 visitor->trace(m_widget);
262 HTMLElement::trace(visitor); 279 HTMLElement::trace(visitor);
263 FrameOwner::trace(visitor); 280 FrameOwner::trace(visitor);
264 } 281 }
265 282
266 283
267 } // namespace blink 284 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698