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

Side by Side Diff: Source/core/frame/Frame.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase past r181245 conflict Created 6 years, 3 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 using namespace HTMLNames; 56 using namespace HTMLNames;
57 57
58 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, frameCounter, ("Frame")); 58 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, frameCounter, ("Frame"));
59 59
60 Frame::Frame(FrameClient* client, FrameHost* host, FrameOwner* owner) 60 Frame::Frame(FrameClient* client, FrameHost* host, FrameOwner* owner)
61 : m_treeNode(this) 61 : m_treeNode(this)
62 , m_host(host) 62 , m_host(host)
63 , m_owner(owner) 63 , m_owner(owner)
64 , m_client(client) 64 , m_client(client)
65 , m_remotePlatformLayer(0) 65 , m_remotePlatformLayer(0)
66 #if ENABLE(OILPAN)
67 , m_disposeProtectionCount(0)
68 , m_hasBeenDisposed(false)
69 #endif
66 { 70 {
67 ASSERT(page()); 71 ASSERT(page());
68 72
69 #ifndef NDEBUG 73 #ifndef NDEBUG
70 frameCounter.increment(); 74 frameCounter.increment();
71 #endif 75 #endif
72 76
73 if (m_owner) { 77 if (m_owner) {
74 page()->incrementSubframeCount(); 78 page()->incrementSubframeCount();
75 if (m_owner->isLocal()) 79 if (m_owner->isLocal())
76 toHTMLFrameOwnerElement(m_owner)->setContentFrame(*this); 80 toHTMLFrameOwnerElement(m_owner)->setContentFrame(*this);
77 } else { 81 } else {
78 page()->setMainFrame(this); 82 page()->setMainFrame(this);
79 } 83 }
80 } 84 }
81 85
82 Frame::~Frame() 86 Frame::~Frame()
83 { 87 {
88 #if ENABLE(OILPAN)
89 // With Oilpan, we depend on the Frame owner explicitly disposing it first.
90 // FIXME: consider also insisting on this non-Oilpan.
91 ASSERT(m_hasBeenDisposed);
92 #else
93 // FIXME: We should not be doing all this work inside the destructor
94 dispose();
95 #endif
96 }
97
98 #if ENABLE(OILPAN)
99 void Frame::willBeDestroyed()
100 {
101 if (m_disposeProtectionCount > 0) {
102 setHasBeenDisposed();
103 return;
104 }
105 if (hasBeenDisposed())
106 return;
107
108 setHasBeenDisposed();
109 dispose();
110 }
111 #endif
112
113 void Frame::dispose()
114 {
84 disconnectOwnerElement(); 115 disconnectOwnerElement();
85 setDOMWindow(nullptr); 116 setDOMWindow(nullptr);
86 117
87 // FIXME: We should not be doing all this work inside the destructor
88
89 #ifndef NDEBUG 118 #ifndef NDEBUG
90 frameCounter.decrement(); 119 frameCounter.decrement();
91 #endif 120 #endif
92 } 121 }
93 122
123 void Frame::trace(Visitor* visitor)
124 {
125 visitor->trace(m_treeNode);
126 visitor->trace(m_owner);
127 visitor->trace(m_domWindow);
128 }
129
94 void Frame::detachChildren() 130 void Frame::detachChildren()
95 { 131 {
96 typedef Vector<RefPtr<Frame> > FrameVector; 132 typedef WillBeHeapVector<RefPtrWillBeMember<Frame> > FrameVector;
97 FrameVector childrenToDetach; 133 FrameVector childrenToDetach;
98 childrenToDetach.reserveCapacity(tree().childCount()); 134 childrenToDetach.reserveCapacity(tree().childCount());
99 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) 135 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling())
100 childrenToDetach.append(child); 136 childrenToDetach.append(child);
101 FrameVector::iterator end = childrenToDetach.end(); 137 FrameVector::iterator end = childrenToDetach.end();
102 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) 138 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it)
103 (*it)->detach(); 139 (*it)->detach();
104 } 140 }
105 141
106 FrameHost* Frame::host() const 142 FrameHost* Frame::host() const
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return 0; 187 return 0;
152 // FIXME: If <object> is ever fixed to disassociate itself from frames 188 // FIXME: If <object> is ever fixed to disassociate itself from frames
153 // that it has started but canceled, then this can turn into an ASSERT 189 // that it has started but canceled, then this can turn into an ASSERT
154 // since ownerElement() would be 0 when the load is canceled. 190 // since ownerElement() would be 0 when the load is canceled.
155 // https://bugs.webkit.org/show_bug.cgi?id=18585 191 // https://bugs.webkit.org/show_bug.cgi?id=18585
156 if (!object->isRenderPart()) 192 if (!object->isRenderPart())
157 return 0; 193 return 0;
158 return toRenderPart(object); 194 return toRenderPart(object);
159 } 195 }
160 196
161 void Frame::setRemotePlatformLayer(blink::WebLayer* layer) 197 void Frame::setRemotePlatformLayer(WebLayer* layer)
162 { 198 {
163 if (m_remotePlatformLayer) 199 if (m_remotePlatformLayer)
164 GraphicsLayer::unregisterContentsLayer(m_remotePlatformLayer); 200 GraphicsLayer::unregisterContentsLayer(m_remotePlatformLayer);
165 m_remotePlatformLayer = layer; 201 m_remotePlatformLayer = layer;
166 if (m_remotePlatformLayer) 202 if (m_remotePlatformLayer)
167 GraphicsLayer::registerContentsLayer(layer); 203 GraphicsLayer::registerContentsLayer(layer);
168 204
169 ASSERT(owner()); 205 ASSERT(owner());
170 toHTMLFrameOwnerElement(owner())->setNeedsCompositingUpdate(); 206 toHTMLFrameOwnerElement(owner())->setNeedsCompositingUpdate();
171 if (RenderPart* renderer = ownerRenderer()) 207 if (RenderPart* renderer = ownerRenderer())
(...skipping 18 matching lines...) Expand all
190 } 226 }
191 227
192 void Frame::disconnectOwnerElement() 228 void Frame::disconnectOwnerElement()
193 { 229 {
194 if (m_owner) { 230 if (m_owner) {
195 if (m_owner->isLocal()) 231 if (m_owner->isLocal())
196 toHTMLFrameOwnerElement(m_owner)->clearContentFrame(); 232 toHTMLFrameOwnerElement(m_owner)->clearContentFrame();
197 if (page()) 233 if (page())
198 page()->decrementSubframeCount(); 234 page()->decrementSubframeCount();
199 } 235 }
200 m_owner = 0; 236 m_owner = nullptr;
201 } 237 }
202 238
203 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const 239 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const
204 { 240 {
205 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0; 241 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0;
206 } 242 }
207 243
208 } // namespace blink 244 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698