Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // If the proposed owner has an existing frame, we're in the midst of a swap . | |
| 74 // This means the old frame didn't go through the normal detach sequence and therefore | |
| 75 // didn't decrement the frame count, so don't increment it here. | |
|
dcheng
2014/10/13 09:17:16
Yikes. It would be nice to keep the swap-specific
| |
| 76 if (m_owner && m_owner->isLocal() && toHTMLFrameOwnerElement(m_owner)->conte ntFrame()) { | |
| 77 toHTMLFrameOwnerElement(m_owner)->contentFrame()->disconnectOwnerElement (); | |
| 78 toHTMLFrameOwnerElement(m_owner)->clearContentFrame(); | |
| 79 } else { | |
| 80 m_host->incrementFrameCount(); | |
| 81 } | |
| 82 | |
| 73 if (m_owner) { | 83 if (m_owner) { |
| 74 page()->incrementSubframeCount(); | |
| 75 if (m_owner->isLocal()) | 84 if (m_owner->isLocal()) |
| 76 toHTMLFrameOwnerElement(m_owner)->setContentFrame(*this); | 85 toHTMLFrameOwnerElement(m_owner)->setContentFrame(*this); |
| 77 } else { | 86 } else { |
| 78 page()->setMainFrame(this); | 87 page()->setMainFrame(this); |
| 79 } | 88 } |
| 80 } | 89 } |
| 81 | 90 |
| 82 Frame::~Frame() | 91 Frame::~Frame() |
| 83 { | 92 { |
| 84 #if ENABLE(OILPAN) | 93 #if ENABLE(OILPAN) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 95 } | 104 } |
| 96 | 105 |
| 97 void Frame::trace(Visitor* visitor) | 106 void Frame::trace(Visitor* visitor) |
| 98 { | 107 { |
| 99 visitor->trace(m_treeNode); | 108 visitor->trace(m_treeNode); |
| 100 visitor->trace(m_host); | 109 visitor->trace(m_host); |
| 101 visitor->trace(m_owner); | 110 visitor->trace(m_owner); |
| 102 visitor->trace(m_domWindow); | 111 visitor->trace(m_domWindow); |
| 103 } | 112 } |
| 104 | 113 |
| 114 void Frame::detach() | |
| 115 { | |
| 116 // client() should never be null because that means we somehow re-entered | |
| 117 // the frame detach code... but it is sometimes. | |
| 118 // FIXME: Understand why this is happening so we can document this insanity. | |
| 119 // http://crbug.com/371084 is a probable explanation. | |
| 120 if (!client()) | |
| 121 return; | |
| 122 // FIXME: Should we enforce the invariant that all pointers nulled in this f unction | |
| 123 // get nulled at the same time? | |
| 124 m_host->decrementFrameCount(); | |
| 125 m_host = nullptr; | |
| 126 // After this, we must no longer talk to the client since this clears | |
| 127 // its owning reference back to our owning LocalFrame. | |
| 128 m_client->detached(); | |
| 129 m_client = nullptr; | |
| 130 } | |
| 131 | |
| 105 void Frame::detachChildren() | 132 void Frame::detachChildren() |
| 106 { | 133 { |
| 107 typedef WillBeHeapVector<RefPtrWillBeMember<Frame> > FrameVector; | 134 typedef WillBeHeapVector<RefPtrWillBeMember<Frame> > FrameVector; |
| 108 FrameVector childrenToDetach; | 135 FrameVector childrenToDetach; |
| 109 childrenToDetach.reserveCapacity(tree().childCount()); | 136 childrenToDetach.reserveCapacity(tree().childCount()); |
| 110 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) | 137 for (Frame* child = tree().firstChild(); child; child = child->tree().nextSi bling()) |
| 111 childrenToDetach.append(child); | 138 childrenToDetach.append(child); |
| 112 FrameVector::iterator end = childrenToDetach.end(); | 139 FrameVector::iterator end = childrenToDetach.end(); |
| 113 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) | 140 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) |
| 114 (*it)->detach(); | 141 (*it)->detach(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 return false; | 223 return false; |
| 197 | 224 |
| 198 if (!tree().parent()) | 225 if (!tree().parent()) |
| 199 return true; | 226 return true; |
| 200 | 227 |
| 201 return tree().parent()->isRemoteFrame(); | 228 return tree().parent()->isRemoteFrame(); |
| 202 } | 229 } |
| 203 | 230 |
| 204 void Frame::disconnectOwnerElement() | 231 void Frame::disconnectOwnerElement() |
| 205 { | 232 { |
| 206 if (m_owner) { | 233 if (m_owner) { |
|
sof
2014/10/13 06:51:00
nit: can fuse the two "if" statements into one.
| |
| 207 if (m_owner->isLocal()) | 234 if (m_owner->isLocal()) |
| 208 toHTMLFrameOwnerElement(m_owner)->clearContentFrame(); | 235 toHTMLFrameOwnerElement(m_owner)->clearContentFrame(); |
| 209 if (page()) | |
| 210 page()->decrementSubframeCount(); | |
| 211 } | 236 } |
| 212 m_owner = nullptr; | 237 m_owner = nullptr; |
| 213 } | 238 } |
| 214 | 239 |
| 215 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const | 240 HTMLFrameOwnerElement* Frame::deprecatedLocalOwner() const |
| 216 { | 241 { |
| 217 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0; | 242 return m_owner && m_owner->isLocal() ? toHTMLFrameOwnerElement(m_owner) : 0; |
| 218 } | 243 } |
| 219 | 244 |
| 220 } // namespace blink | 245 } // namespace blink |
| OLD | NEW |