Bug 730601 - Don't use GetListenerManager(false) to check existence of ELM, but HasListenerManager, r=jst

This commit is contained in:
Olli Pettay 2012-02-27 16:03:15 +02:00
parent a7a7967bca
commit b4ba8dce02
4 changed files with 13 additions and 7 deletions

View File

@ -89,8 +89,7 @@ class Element;
} // namespace mozilla
enum {
// This bit will be set if the node has a listener manager in the listener
// manager hash
// This bit will be set if the node has a listener manager.
NODE_HAS_LISTENERMANAGER = 0x00000001U,
// Whether this node has had any properties set on it
@ -1308,6 +1307,7 @@ public:
{ SetBoolFlag(NodeIsPurpleRoot, aValue); }
bool IsPurpleRoot() const { return GetBoolFlag(NodeIsPurpleRoot); }
bool HasListenerManager() { return HasFlag(NODE_HAS_LISTENERMANAGER); }
protected:
void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
void SetInDocument() { SetBoolFlag(IsInDocument); }

View File

@ -1636,6 +1636,7 @@ nsDocument::~nsDocument()
if (mListenerManager) {
mListenerManager->Disconnect();
UnsetFlags(NODE_HAS_LISTENERMANAGER);
}
if (mScriptLoader) {
@ -1950,6 +1951,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
if (tmp->mListenerManager) {
tmp->mListenerManager->Disconnect();
tmp->UnsetFlags(NODE_HAS_LISTENERMANAGER);
tmp->mListenerManager = nsnull;
}
@ -6215,6 +6217,7 @@ nsDocument::GetListenerManager(bool aCreateIfNotFound)
if (!mListenerManager && aCreateIfNotFound) {
mListenerManager =
new nsEventListenerManager(static_cast<nsIDOMEventTarget*>(this));
SetFlags(NODE_HAS_LISTENERMANAGER);
}
return mListenerManager;

View File

@ -1268,7 +1268,8 @@ nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb)
nsNodeUtils::TraverseUserData(tmp, cb);
}
if (tmp->HasFlag(NODE_HAS_LISTENERMANAGER)) {
if (tmp->NodeType() != nsIDOMNode::DOCUMENT_NODE &&
tmp->HasFlag(NODE_HAS_LISTENERMANAGER)) {
nsContentUtils::TraverseListenerManager(tmp, cb);
}
@ -1286,7 +1287,8 @@ nsINode::Unlink(nsINode *tmp)
slots->Unlink();
}
if (tmp->HasFlag(NODE_HAS_LISTENERMANAGER)) {
if (tmp->NodeType() != nsIDOMNode::DOCUMENT_NODE &&
tmp->HasFlag(NODE_HAS_LISTENERMANAGER)) {
nsContentUtils::RemoveListenerManager(tmp);
tmp->UnsetFlags(NODE_HAS_LISTENERMANAGER);
}
@ -3375,7 +3377,7 @@ nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{
//FIXME! Document how this event retargeting works, Bug 329124.
aVisitor.mCanHandle = true;
aVisitor.mMayHaveListenerManager = HasFlag(NODE_HAS_LISTENERMANAGER);
aVisitor.mMayHaveListenerManager = HasListenerManager();
// Don't propagate mouseover and mouseout events when mouse is moving
// inside native anonymous content.
@ -4628,7 +4630,7 @@ ShouldClearPurple(nsIContent* aContent)
return true;
}
if (aContent->GetListenerManager(false)) {
if (aContent->HasListenerManager()) {
return true;
}

View File

@ -282,7 +282,8 @@ nsNodeUtils::LastRelease(nsINode* aNode)
}
aNode->UnsetFlags(NODE_HAS_PROPERTIES);
if (aNode->HasFlag(NODE_HAS_LISTENERMANAGER)) {
if (aNode->NodeType() != nsIDOMNode::DOCUMENT_NODE &&
aNode->HasFlag(NODE_HAS_LISTENERMANAGER)) {
#ifdef DEBUG
if (nsContentUtils::IsInitialized()) {
nsEventListenerManager* manager =