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

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: Rebased upto r183571 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 38
38 namespace blink { 39 namespace blink {
39 40
40 typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap; 41 typedef WillBeHeapHashMap<RefPtrWillBeMember<Widget>, RawPtrWillBeMember<FrameVi ew> > WidgetToParentMap;
41 static WidgetToParentMap& widgetNewParentMap() 42 static WidgetToParentMap& widgetNewParentMap()
42 { 43 {
43 DEFINE_STATIC_LOCAL(WidgetToParentMap, map, ()); 44 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WidgetToParentMap>, map, (adoptPt rWillBeNoop(new WidgetToParentMap())));
44 return map; 45 return *map;
45 } 46 }
46 47
47 WillBeHeapHashCountedSet<RawPtrWillBeMember<Node> >& SubframeLoadingDisabler::di sabledSubtreeRoots() 48 WillBeHeapHashCountedSet<RawPtrWillBeMember<Node> >& SubframeLoadingDisabler::di sabledSubtreeRoots()
48 { 49 {
49 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashCountedSet<RawPtrWi llBeMember<Node> > >, nodes, (adoptPtrWillBeNoop(new WillBeHeapHashCountedSet<Ra wPtrWillBeMember<Node> >()))); 50 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashCountedSet<RawPtrWi llBeMember<Node> > >, nodes, (adoptPtrWillBeNoop(new WillBeHeapHashCountedSet<Ra wPtrWillBeMember<Node> >())));
50 return *nodes; 51 return *nodes;
51 } 52 }
52 53
53 static unsigned s_updateSuspendCount = 0; 54 static unsigned s_updateSuspendCount = 0;
54 55
55 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope() 56 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope()
56 { 57 {
57 ++s_updateSuspendCount; 58 ++s_updateSuspendCount;
58 } 59 }
59 60
60 void HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOperati ons() 61 void HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOperati ons()
61 { 62 {
62 WidgetToParentMap map; 63 WidgetToParentMap map;
63 widgetNewParentMap().swap(map); 64 widgetNewParentMap().swap(map);
64 WidgetToParentMap::iterator end = map.end(); 65 WidgetToParentMap::iterator end = map.end();
65 for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) { 66 for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) {
66 Widget* child = it->key.get(); 67 Widget* child = it->key.get();
67 FrameView* currentParent = toFrameView(child->parent()); 68 FrameView* currentParent = toFrameView(child->parent());
68 FrameView* newParent = it->value; 69 FrameView* newParent = it->value;
69 if (newParent != currentParent) { 70 if (newParent != currentParent) {
70 if (currentParent) 71 if (currentParent)
71 currentParent->removeChild(child); 72 currentParent->removeChild(child);
72 if (newParent) 73 if (newParent)
73 newParent->addChild(child); 74 newParent->addChild(child);
75 #if ENABLE(OILPAN)
76 if (currentParent && !newParent)
77 child->dispose();
78 #endif
74 } 79 }
75 } 80 }
76 } 81 }
77 82
78 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope() 83 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope()
79 { 84 {
80 ASSERT(s_updateSuspendCount > 0); 85 ASSERT(s_updateSuspendCount > 0);
81 if (s_updateSuspendCount == 1) 86 if (s_updateSuspendCount == 1)
82 performDeferredWidgetTreeOperations(); 87 performDeferredWidgetTreeOperations();
83 --s_updateSuspendCount; 88 --s_updateSuspendCount;
84 } 89 }
85 90
86 static void moveWidgetToParentSoon(Widget* child, FrameView* parent) 91 static void moveWidgetToParentSoon(Widget* child, FrameView* parent)
87 { 92 {
88 if (!s_updateSuspendCount) { 93 if (!s_updateSuspendCount) {
89 if (parent) 94 if (parent) {
90 parent->addChild(child); 95 parent->addChild(child);
91 else if (toFrameView(child->parent())) 96 } else if (toFrameView(child->parent())) {
92 toFrameView(child->parent())->removeChild(child); 97 toFrameView(child->parent())->removeChild(child);
98 #if ENABLE(OILPAN)
99 child->dispose();
100 #endif
101 }
93 return; 102 return;
94 } 103 }
95 widgetNewParentMap().set(child, parent); 104 widgetNewParentMap().set(child, parent);
96 } 105 }
97 106
98 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum ent& document) 107 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum ent& document)
99 : HTMLElement(tagName, document) 108 : HTMLElement(tagName, document)
100 , m_contentFrame(nullptr) 109 , m_contentFrame(nullptr)
101 , m_widget(nullptr) 110 , m_widget(nullptr)
102 , m_sandboxFlags(SandboxNone) 111 , m_sandboxFlags(SandboxNone)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 145 }
137 146
138 void HTMLFrameOwnerElement::disconnectContentFrame() 147 void HTMLFrameOwnerElement::disconnectContentFrame()
139 { 148 {
140 // FIXME: Currently we don't do this in removedFrom because this causes an 149 // FIXME: Currently we don't do this in removedFrom because this causes an
141 // unload event in the subframe which could execute script that could then 150 // unload event in the subframe which could execute script that could then
142 // reach up into this document and then attempt to look back down. We should 151 // reach up into this document and then attempt to look back down. We should
143 // see if this behavior is really needed as Gecko does not allow this. 152 // see if this behavior is really needed as Gecko does not allow this.
144 if (RefPtrWillBeRawPtr<Frame> frame = contentFrame()) { 153 if (RefPtrWillBeRawPtr<Frame> frame = contentFrame()) {
145 frame->detach(); 154 frame->detach();
146 #if ENABLE(OILPAN)
147 // FIXME: Oilpan: the plugin container is released and finalized here
148 // in order to work around the current inability to make the plugin
149 // container a FrameDestructionObserver (it needs to effectively be on
150 // the heap, and Widget isn't). Hence, release it here while its
151 // frame reference is still valid.
152 if (m_widget && m_widget->isPluginContainer())
153 m_widget = nullptr;
154 #endif
155 frame->disconnectOwnerElement(); 155 frame->disconnectOwnerElement();
156 } 156 }
157 #if ENABLE(OILPAN)
158 // Oilpan: a plugin container must be explicitly disposed before it
159 // is swept and finalized. This is because the underlying plugin needs
160 // to be able to access a fully-functioning frame (and all it refers
161 // to) while it destructs and cleans out its resources.
162 if (m_widget) {
163 m_widget->dispose();
164 m_widget = nullptr;
165 }
166 #endif
157 } 167 }
158 168
159 HTMLFrameOwnerElement::~HTMLFrameOwnerElement() 169 HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
160 { 170 {
161 #if ENABLE(OILPAN) 171 #if ENABLE(OILPAN)
162 // An owner must by now have been informed of detachment 172 // An owner must by now have been informed of detachment
163 // when the frame was closed. 173 // when the frame was closed.
164 ASSERT(!m_contentFrame); 174 ASSERT(!m_contentFrame);
165 #else 175 #else
166 if (m_contentFrame) 176 if (m_contentFrame)
(...skipping 27 matching lines...) Expand all
194 } 204 }
195 205
196 Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionState& exceptionState) const 206 Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionState& exceptionState) const
197 { 207 {
198 Document* doc = contentDocument(); 208 Document* doc = contentDocument();
199 if (doc && doc->isSVGDocument()) 209 if (doc && doc->isSVGDocument())
200 return doc; 210 return doc;
201 return 0; 211 return 0;
202 } 212 }
203 213
204 void HTMLFrameOwnerElement::setWidget(PassRefPtr<Widget> widget) 214 void HTMLFrameOwnerElement::setWidget(PassRefPtrWillBeRawPtr<Widget> widget)
205 { 215 {
206 if (widget == m_widget) 216 if (widget == m_widget)
207 return; 217 return;
208 218
209 if (m_widget) { 219 if (m_widget) {
210 if (m_widget->parent()) 220 if (m_widget->parent())
211 moveWidgetToParentSoon(m_widget.get(), 0); 221 moveWidgetToParentSoon(m_widget.get(), 0);
212 m_widget = nullptr; 222 m_widget = nullptr;
213 } 223 }
214 224
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 260
251 if (!SubframeLoadingDisabler::canLoadFrame(*this)) 261 if (!SubframeLoadingDisabler::canLoadFrame(*this))
252 return false; 262 return false;
253 263
254 return parentFrame->loader().client()->createFrame(url, frameName, this); 264 return parentFrame->loader().client()->createFrame(url, frameName, this);
255 } 265 }
256 266
257 void HTMLFrameOwnerElement::trace(Visitor* visitor) 267 void HTMLFrameOwnerElement::trace(Visitor* visitor)
258 { 268 {
259 visitor->trace(m_contentFrame); 269 visitor->trace(m_contentFrame);
270 visitor->trace(m_widget);
260 HTMLElement::trace(visitor); 271 HTMLElement::trace(visitor);
261 FrameOwner::trace(visitor); 272 FrameOwner::trace(visitor);
262 } 273 }
263 274
264 275
265 } // namespace blink 276 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698