diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp index 7365c07bfe45..4900b1d13639 100644 --- a/content/base/src/nsContentList.cpp +++ b/content/base/src/nsContentList.cpp @@ -47,9 +47,9 @@ #include "nsIDOMNode.h" #include "nsIDocument.h" #include "nsGenericElement.h" - +#include "nsWrapperCacheInlines.h" #include "nsContentUtils.h" - +#include "nsCCUncollectableMarker.h" #include "nsGkAtoms.h" #include "dombindings.h" @@ -80,8 +80,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsBaseContentList) NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBaseContentList) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mElements) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS + if (nsCCUncollectableMarker::sGeneration && tmp->IsBlack()) { + return NS_SUCCESS_INTERRUPTED_TRAVERSE; + } + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mElements) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsBaseContentList) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 49e7610c94d1..6f9e76ce17a5 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1207,13 +1207,6 @@ nsINode::Trace(nsINode *tmp, TraceCallback cb, void *closure) nsContentUtils::TraceWrapper(tmp, cb, closure); } -static bool -IsBlackNode(nsINode* aNode) -{ - JSObject* o = aNode->GetWrapperPreserveColor(); - return o && !xpc_IsGrayGCThing(o); -} - static bool IsXBL(nsINode* aNode) { @@ -1233,7 +1226,7 @@ nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb) if (nsCCUncollectableMarker::sGeneration) { // If we're black no need to traverse. - if (IsBlackNode(tmp)) { + if (tmp->IsBlack()) { return false; } @@ -1246,13 +1239,13 @@ nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb) if (!tmp->HasFlag(problematicFlags) && !IsXBL(tmp)) { // If we're in a black document, return early. - if ((currentDoc && IsBlackNode(currentDoc))) { + if ((currentDoc && currentDoc->IsBlack())) { return false; } // If we're not in anonymous content and we have a black parent, // return early. nsIContent* parent = tmp->GetParent(); - if (parent && !IsXBL(parent) && IsBlackNode(parent)) { + if (parent && !IsXBL(parent) && parent->IsBlack()) { NS_ABORT_IF_FALSE(parent->IndexOf(tmp) >= 0, "Parent doesn't own us?"); return false; } diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index e330f2fe3b44..a8f2f7c57e6d 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -190,6 +190,11 @@ public: return nsnull; } + /** + * Returns true if the object has a non-gray wrapper. + */ + bool IsBlack(); + private: // Only meant to be called by nsContentUtils. void SetPreservingWrapper(bool aPreserve) diff --git a/dom/base/nsWrapperCacheInlines.h b/dom/base/nsWrapperCacheInlines.h index a1129e9ab2d9..ddd44cd91e94 100644 --- a/dom/base/nsWrapperCacheInlines.h +++ b/dom/base/nsWrapperCacheInlines.h @@ -139,4 +139,11 @@ nsWrapperCache::ClearWrapperIfProxy() SetWrapperBits(NULL); } +inline bool +nsWrapperCache::IsBlack() +{ + JSObject* o = GetWrapperPreserveColor(); + return o && !xpc_IsGrayGCThing(o); +} + #endif /* nsWrapperCache_h___ */