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

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

Issue 551973005: Streamline frame detach (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/Frame.h ('k') | Source/core/frame/FrameClient.h » ('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) 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 66 {
67 ASSERT(page()); 67 ASSERT(page());
68 68
69 #ifndef NDEBUG 69 #ifndef NDEBUG
70 frameCounter.increment(); 70 frameCounter.increment();
71 #endif 71 #endif
72 72
73 m_host->incrementFrameCount();
74
73 if (m_owner) { 75 if (m_owner) {
74 page()->incrementSubframeCount();
75 if (m_owner->isLocal()) 76 if (m_owner->isLocal())
76 toHTMLFrameOwnerElement(m_owner)->setContentFrame(*this); 77 toHTMLFrameOwnerElement(m_owner)->setContentFrame(*this);
77 } else { 78 } else {
78 page()->setMainFrame(this); 79 page()->setMainFrame(this);
79 } 80 }
80 } 81 }
81 82
82 Frame::~Frame() 83 Frame::~Frame()
83 { 84 {
84 disconnectOwnerElement(); 85 disconnectOwnerElement();
85 setDOMWindow(nullptr); 86 setDOMWindow(nullptr);
86 87
87 // FIXME: We should not be doing all this work inside the destructor 88 // FIXME: We should not be doing all this work inside the destructor
88 89
89 #ifndef NDEBUG 90 #ifndef NDEBUG
90 frameCounter.decrement(); 91 frameCounter.decrement();
91 #endif 92 #endif
92 } 93 }
93 94
95 void Frame::detach()
96 {
97 // client() should never be null because that means we somehow re-entered
98 // the frame detach code... but it is sometimes.
99 // FIXME: Understand why this is happening so we can document this insanity.
dcheng 2014/09/16 19:46:11 I think (but could be wrong) that this is actually
100 if (!client())
101 return;
102 m_host->decrementFrameCount();
103 m_host = 0;
104 // After this, we must no longer talk to the client since this clears
105 // its owning reference back to our owning LocalFrame.
106 m_client->detached();
107 m_client = 0;
108 }
109
94 void Frame::detachChildren() 110 void Frame::detachChildren()
95 { 111 {
96 typedef Vector<RefPtr<Frame> > FrameVector; 112 typedef Vector<RefPtr<Frame> > FrameVector;
97 FrameVector childrenToDetach; 113 FrameVector childrenToDetach;
98 childrenToDetach.reserveCapacity(tree().childCount()); 114 childrenToDetach.reserveCapacity(tree().childCount());
99 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) 115 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling())
100 childrenToDetach.append(child); 116 childrenToDetach.append(child);
101 FrameVector::iterator end = childrenToDetach.end(); 117 FrameVector::iterator end = childrenToDetach.end();
102 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) 118 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it)
103 (*it)->detach(); 119 (*it)->detach();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return true; 203 return true;
188 204
189 return tree().parent()->isRemoteFrame(); 205 return tree().parent()->isRemoteFrame();
190 } 206 }
191 207
192 void Frame::disconnectOwnerElement() 208 void Frame::disconnectOwnerElement()
193 { 209 {
194 if (m_owner) { 210 if (m_owner) {
195 if (m_owner->isLocal()) 211 if (m_owner->isLocal())
196 toHTMLFrameOwnerElement(m_owner)->clearContentFrame(); 212 toHTMLFrameOwnerElement(m_owner)->clearContentFrame();
197 if (page())
198 page()->decrementSubframeCount();
199 } 213 }
200 m_owner = 0; 214 m_owner = 0;
201 } 215 }
202 216
203 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const 217 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const
204 { 218 {
205 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0; 219 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0;
206 } 220 }
207 221
208 } // namespace blink 222 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/Frame.h ('k') | Source/core/frame/FrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698