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

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, 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 | 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 #if ENABLE(OILPAN) 85 #if ENABLE(OILPAN)
(...skipping 10 matching lines...) Expand all
95 } 96 }
96 97
97 void Frame::trace(Visitor* visitor) 98 void Frame::trace(Visitor* visitor)
98 { 99 {
99 visitor->trace(m_treeNode); 100 visitor->trace(m_treeNode);
100 visitor->trace(m_host); 101 visitor->trace(m_host);
101 visitor->trace(m_owner); 102 visitor->trace(m_owner);
102 visitor->trace(m_domWindow); 103 visitor->trace(m_domWindow);
103 } 104 }
104 105
106 void Frame::detach()
107 {
108 // client() should never be null because that means we somehow re-entered
109 // the frame detach code... but it is sometimes.
110 // FIXME: Understand why this is happening so we can document this insanity.
111 // http://crbug.com/371084 is a probable explanation.
112 if (!client())
113 return;
114 // FIXME: Should we enforce the invariant that all pointers nulled in this f unction
115 // get nulled at the same time?
116 m_host->decrementFrameCount();
117 m_host = nullptr;
118 // After this, we must no longer talk to the client since this clears
119 // its owning reference back to our owning LocalFrame.
120 m_client->detached();
121 m_client = nullptr;
122 }
123
105 void Frame::detachChildren() 124 void Frame::detachChildren()
106 { 125 {
107 typedef WillBeHeapVector<RefPtrWillBeMember<Frame> > FrameVector; 126 typedef WillBeHeapVector<RefPtrWillBeMember<Frame> > FrameVector;
108 FrameVector childrenToDetach; 127 FrameVector childrenToDetach;
109 childrenToDetach.reserveCapacity(tree().childCount()); 128 childrenToDetach.reserveCapacity(tree().childCount());
110 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) 129 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling())
111 childrenToDetach.append(child); 130 childrenToDetach.append(child);
112 FrameVector::iterator end = childrenToDetach.end(); 131 FrameVector::iterator end = childrenToDetach.end();
113 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) 132 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it)
114 (*it)->detach(); 133 (*it)->detach();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return true; 218 return true;
200 219
201 return tree().parent()->isRemoteFrame(); 220 return tree().parent()->isRemoteFrame();
202 } 221 }
203 222
204 void Frame::disconnectOwnerElement() 223 void Frame::disconnectOwnerElement()
205 { 224 {
206 if (m_owner) { 225 if (m_owner) {
207 if (m_owner->isLocal()) 226 if (m_owner->isLocal())
208 toHTMLFrameOwnerElement(m_owner)->clearContentFrame(); 227 toHTMLFrameOwnerElement(m_owner)->clearContentFrame();
209 if (page())
210 page()->decrementSubframeCount();
211 } 228 }
212 m_owner = nullptr; 229 m_owner = nullptr;
213 } 230 }
214 231
215 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const 232 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const
216 { 233 {
217 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0; 234 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0;
218 } 235 }
219 236
220 } // namespace blink 237 } // 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