Changeset 25813 in webkit
- Timestamp:
- Sep 30, 2007 6:54:09 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r25808 r25813 1 2007-09-30 Darin Adler <darin@apple.com> 2 3 Reviewed by Maciej. 4 5 - tone down the assertion I asked Harrison to include in his fix for 6 <rdar://problem/5511128>; it's OK to re-ref and deref the document 7 as long as you do so after the children are done being destroyed 8 9 No effect on release builds. Assertion change only. 10 11 Besides the changes listed below, renamed m_hasDeleted flag to 12 m_deletionHasBegun. 13 14 * dom/ContainerNode.cpp: (WebCore::ContainerNode::removeAllChildren): 15 Added code to set the m_deletionHasBegun flag and some assertions 16 that test its state. 17 18 * dom/Document.h: Removed m_hasDeleted -- we now use m_deletionHasBegun 19 in the base class TreeShared. 20 * dom/Document.cpp: 21 (WebCore::Document::Document): Removed initialization of m_hasDeleted. 22 (WebCore::Document::removedLastRef): Added code to clear 23 m_inRemovedLastRefFunction if we end up deciding not to delete this. 24 25 * platform/Shared.h: 26 (WebCore::TreeShared::TreeShared): Added m_deletionHasBegun in addition to 27 m_inRemovedLastRefFunction (formerly named m_hasRemovedLastRef). 28 (WebCore::TreeShared::~TreeShared): Assert that m_deletionHasBegun is true. 29 (WebCore::TreeShared::ref): Assert neither flag is true. 30 (WebCore::TreeShared::deref): Ditto. 31 (WebCore::TreeShared::hasOneRef): Ditto. 32 (WebCore::TreeShared::removedLastRef): Made private. Added code to 33 set m_hasDeleted to true. Also removed cast; since this class template 34 has a virtual destructor, we don't need to cast before calling delete. 35 1 36 2007-09-29 Holger Hans Peter Freyther <zecke@selfish.org> 2 37 … … 96 131 97 132 - <rdar://5261371> Nothing downloaded when exporting bookmarks from iGoogle web history 98 - Implemented IWebHTTPURLResponse::allHeaderFields so that if the content disposition is "attachment" we will download the file instead of display it. Also implemented some missing functionality. 133 134 Function for use by WebKit. Currently used only on Windows. 99 135 100 136 * platform/network/ResourceResponse.cpp: -
trunk/WebCore/dom/ContainerNode.cpp
r25797 r25813 63 63 if (topLevel) 64 64 alreadyInsideDestructor = true; 65 65 66 66 // List of nodes to be deleted. 67 static Node *head;68 static Node *tail;69 67 static Node* head; 68 static Node* tail; 69 70 70 // We have to tell all children that their parent has died. 71 Node *n; 72 Node *next; 73 74 for (n = m_firstChild; n != 0; n = next ) { 71 Node* n; 72 Node* next; 73 for (n = m_firstChild; n != 0; n = next) { 74 ASSERT(!n->m_deletionHasBegun); 75 75 76 next = n->nextSibling(); 76 77 n->setPreviousSibling(0); … … 78 79 n->setParent(0); 79 80 80 if ( !n->refCount() ) { 81 if (!n->refCount()) { 82 #ifndef NDEBUG 83 n->m_deletionHasBegun = true; 84 #endif 81 85 // Add the node to the list of nodes to be deleted. 82 86 // Reuse the nextSibling pointer for this purpose. … … 89 93 n->removedFromDocument(); 90 94 } 91 95 92 96 // Only for the top level call, do the actual deleting. 93 97 if (topLevel) { 94 98 while ((n = head) != 0) { 99 ASSERT(n->m_deletionHasBegun); 100 95 101 next = n->nextSibling(); 96 102 n->setNextSibling(0); … … 99 105 if (next == 0) 100 106 tail = 0; 101 107 102 108 delete n; 103 109 } 104 110 105 111 alreadyInsideDestructor = false; 106 112 m_firstChild = 0; -
trunk/WebCore/dom/Document.cpp
r25797 r25813 268 268 , m_designMode(inherit) 269 269 , m_selfOnlyRefCount(0) 270 #ifndef NDEBUG271 , m_hasDeleted(false)272 #endif273 270 #if ENABLE(SVG) 274 271 , m_svgExtensions(0) … … 345 342 void Document::removedLastRef() 346 343 { 347 ASSERT(!m_ hasDeleted);344 ASSERT(!m_deletionHasBegun); 348 345 if (m_selfOnlyRefCount) { 349 // if removing a child removes the last self-only ref, we don't346 // If removing a child removes the last self-only ref, we don't 350 347 // want the document to be destructed until after 351 348 // removeAllChildren returns, so we guard ourselves with an 352 // extra self-only ref 349 // extra self-only ref. 353 350 354 351 DocPtr<Document> guard(this); 355 352 356 // we must make sure not to be retaining any of our children through357 // these extra pointers or we will create a reference cycle 353 // We must make sure not to be retaining any of our children through 354 // these extra pointers or we will create a reference cycle. 358 355 m_docType = 0; 359 356 m_focusedNode = 0; … … 370 367 delete m_tokenizer; 371 368 m_tokenizer = 0; 369 370 #ifndef NDEBUG 371 m_inRemovedLastRefFunction = false; 372 #endif 372 373 } else { 373 374 #ifndef NDEBUG 374 m_ hasDeleted= true;375 m_deletionHasBegun = true; 375 376 #endif 376 377 delete this; -
trunk/WebCore/dom/Document.h
r25797 r25813 150 150 void selfOnlyRef() 151 151 { 152 ASSERT(!m_ hasDeleted);152 ASSERT(!m_deletionHasBegun); 153 153 ++m_selfOnlyRefCount; 154 154 } 155 155 void selfOnlyDeref() 156 156 { 157 ASSERT(!m_ hasDeleted);157 ASSERT(!m_deletionHasBegun); 158 158 --m_selfOnlyRefCount; 159 159 if (!m_selfOnlyRefCount && !refCount()) { 160 160 #ifndef NDEBUG 161 m_ hasDeleted= true;161 m_deletionHasBegun = true; 162 162 #endif 163 163 delete this; … … 883 883 884 884 int m_selfOnlyRefCount; 885 #ifndef NDEBUG886 bool m_hasDeleted;887 #endif888 885 889 886 HTMLFormElement::CheckedRadioButtons m_checkedRadioButtons; -
trunk/WebCore/platform/Shared.h
r25797 r25813 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 32 32 : m_refCount(0) 33 33 #ifndef NDEBUG 34 , m_ hasDeleted(false)34 , m_deletionHasBegun(false) 35 35 #endif 36 36 { … … 39 39 void ref() 40 40 { 41 ASSERT(!m_ hasDeleted);41 ASSERT(!m_deletionHasBegun); 42 42 ++m_refCount; 43 43 } … … 45 45 void deref() 46 46 { 47 ASSERT(!m_ hasDeleted);47 ASSERT(!m_deletionHasBegun); 48 48 if (--m_refCount <= 0) { 49 49 #ifndef NDEBUG 50 m_ hasDeleted= true;50 m_deletionHasBegun = true; 51 51 #endif 52 52 delete static_cast<T*>(this); … … 56 56 bool hasOneRef() 57 57 { 58 ASSERT(!m_ hasDeleted);58 ASSERT(!m_deletionHasBegun); 59 59 return m_refCount == 1; 60 60 } … … 68 68 int m_refCount; 69 69 #ifndef NDEBUG 70 bool m_ hasDeleted;70 bool m_deletionHasBegun; 71 71 #endif 72 72 }; … … 77 77 : m_refCount(0) 78 78 , m_parent(0) 79 { 79 80 #ifndef NDEBUG 80 , m_hasRemovedLastRef(false) 81 m_deletionHasBegun = false; 82 m_inRemovedLastRefFunction = false; 81 83 #endif 82 {83 84 } 84 85 TreeShared(T* parent) 85 86 : m_refCount(0) 86 , m_parent(parent) 87 , m_parent(0) 88 { 87 89 #ifndef NDEBUG 88 , m_hasRemovedLastRef(false) 90 m_deletionHasBegun = false; 91 m_inRemovedLastRefFunction = false; 89 92 #endif 93 } 94 virtual ~TreeShared() 90 95 { 96 ASSERT(m_deletionHasBegun); 91 97 } 92 virtual ~TreeShared() { }93 94 virtual void removedLastRef() { delete static_cast<T*>(this); }95 98 96 99 void ref() 97 100 { 98 ASSERT(!m_hasRemovedLastRef); 101 ASSERT(!m_deletionHasBegun); 102 ASSERT(!m_inRemovedLastRefFunction); 99 103 ++m_refCount; 100 104 } … … 102 106 void deref() 103 107 { 104 ASSERT(!m_hasRemovedLastRef); 108 ASSERT(!m_deletionHasBegun); 109 ASSERT(!m_inRemovedLastRefFunction); 105 110 if (--m_refCount <= 0 && !m_parent) { 106 111 #ifndef NDEBUG 107 m_ hasRemovedLastRef= true;112 m_inRemovedLastRefFunction = true; 108 113 #endif 109 114 removedLastRef(); … … 113 118 bool hasOneRef() const 114 119 { 115 ASSERT(!m_hasRemovedLastRef); 120 ASSERT(!m_deletionHasBegun); 121 ASSERT(!m_inRemovedLastRefFunction); 116 122 return m_refCount == 1; 117 123 } … … 125 131 T* parent() const { return m_parent; } 126 132 133 #ifndef NDEBUG 134 bool m_deletionHasBegun; 135 bool m_inRemovedLastRefFunction; 136 #endif 137 127 138 private: 139 virtual void removedLastRef() 140 { 141 #ifndef NDEBUG 142 m_deletionHasBegun = true; 143 #endif 144 delete this; 145 } 146 128 147 int m_refCount; 129 148 T* m_parent; 130 #ifndef NDEBUG131 bool m_hasRemovedLastRef;132 #endif133 149 }; 134 150
Note: See TracChangeset
for help on using the changeset viewer.