Back out patch for bug 423355 due to unit test failures

This commit is contained in:
gavin@gavinsharp.com 2008-04-04 18:11:50 -07:00
Родитель 67909defd6
Коммит e5cca7ed9b
8 изменённых файлов: 98 добавлений и 121 удалений

Просмотреть файл

@ -595,6 +595,8 @@ public:
// To make this easy and painless, use the mozAutoDocUpdate helper class.
virtual void BeginUpdate(nsUpdateType aUpdateType) = 0;
virtual void EndUpdate(nsUpdateType aUpdateType) = 0;
virtual PRUint32 GetUpdateNestingLevel() = 0;
virtual PRBool AllUpdatesAreContent() = 0;
virtual void BeginLoad() = 0;
virtual void EndLoad() = 0;
// notify that one or two content nodes changed state
@ -975,22 +977,6 @@ protected:
friend class mozAutoSubtreeModified;
friend class nsPresShellIterator;
/**
* Get/Set the current number of removable updates. Currently only
* UPDATE_CONTENT_MODEL updates are removable, and only when firing mutation
* events. These functions should only be called by mozAutoDocUpdateRemover.
* The count is also adjusted by the normal calls to BeginUpdate/EndUpdate.
*/
PRUint32 GetRemovableUpdateLevel()
{
return mRemovableUpdateLevel;
}
void SetRemovableUpdateLevel(PRUint32 aLevel)
{
mRemovableUpdateLevel = aLevel;
}
friend class mozAutoDocUpdateRemover;
nsString mDocumentTitle;
nsCOMPtr<nsIURI> mDocumentURI;
nsCOMPtr<nsIURI> mDocumentBaseURI;
@ -1061,9 +1047,6 @@ protected:
// won't be collected
PRUint32 mMarkedCCGeneration;
// Current number of removable updates.
PRUint32 mRemovableUpdateLevel;
nsTObserverArray<nsIPresShell*> mPresShells;
nsCOMArray<nsINode> mSubtreeModifiedTargets;

Просмотреть файл

@ -4012,7 +4012,6 @@ nsContentUtils::AddScriptBlocker()
void
nsContentUtils::RemoveScriptBlocker()
{
NS_ASSERTION(sScriptBlockerCount != 0, "Negative script blockers");
--sScriptBlockerCount;
if (sScriptBlockerCount) {
return;

Просмотреть файл

@ -2706,7 +2706,7 @@ nsDocument::BeginUpdate(nsUpdateType aUpdateType)
++mUpdateNestLevel;
if (aUpdateType == UPDATE_CONTENT_MODEL) {
++mRemovableUpdateLevel;
++mContentUpdateNestLevel;
}
NS_DOCUMENT_NOTIFY_OBSERVERS(BeginUpdate, (this, aUpdateType));
@ -2720,8 +2720,7 @@ nsDocument::EndUpdate(nsUpdateType aUpdateType)
NS_DOCUMENT_NOTIFY_OBSERVERS(EndUpdate, (this, aUpdateType));
if (aUpdateType == UPDATE_CONTENT_MODEL) {
NS_ASSERTION(mRemovableUpdateLevel != 0, "level going below 0");
--mRemovableUpdateLevel;
--mContentUpdateNestLevel;
}
--mUpdateNestLevel;
if (mUpdateNestLevel == 0) {
@ -2751,6 +2750,18 @@ nsDocument::EndUpdate(nsUpdateType aUpdateType)
}
}
PRUint32
nsDocument::GetUpdateNestingLevel()
{
return mUpdateNestLevel;
}
PRBool
nsDocument::AllUpdatesAreContent()
{
return mContentUpdateNestLevel == mUpdateNestLevel;
}
void
nsDocument::BeginLoad()
{
@ -5850,12 +5861,10 @@ nsDocument::MutationEventDispatched(nsINode* aTarget)
PRInt32 realTargetCount = realTargets.Count();
for (PRInt32 k = 0; k < realTargetCount; ++k) {
mozAutoDocUpdateRemover updateRemover(this);
mozAutoDocUpdateContentUnnest updateUnnest(this);
if (nsContentUtils::IsSafeToRunScript()) {
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_SUBTREEMODIFIED);
nsEventDispatcher::Dispatch(realTargets[k], nsnull, &mutation);
}
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_SUBTREEMODIFIED);
nsEventDispatcher::Dispatch(realTargets[k], nsnull, &mutation);
}
}
}

Просмотреть файл

@ -474,6 +474,8 @@ public:
// observers.
virtual void BeginUpdate(nsUpdateType aUpdateType);
virtual void EndUpdate(nsUpdateType aUpdateType);
virtual PRUint32 GetUpdateNestingLevel();
virtual PRBool AllUpdatesAreContent();
virtual void BeginLoad();
virtual void EndLoad();
virtual void ContentStatesChanged(nsIContent* aContent1,
@ -800,6 +802,8 @@ protected:
// Our update nesting level
PRUint32 mUpdateNestLevel;
// Our UPDATE_CONTENT_MODEL update nesting level
PRUint32 mContentUpdateNestLevel;
private:
friend class nsUnblockOnloadEvent;

Просмотреть файл

@ -497,21 +497,19 @@ nsGenericDOMDataNode::SetTextInternal(PRUint32 aOffset, PRUint32 aCount,
nsNodeUtils::CharacterDataChanged(this, &info);
if (haveMutationListeners) {
mozAutoDocUpdateRemover updateRemover(document);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_CHARACTERDATAMODIFIED);
if (nsContentUtils::IsSafeToRunScript()) {
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_CHARACTERDATAMODIFIED);
mutation.mPrevAttrValue = oldValue;
if (aLength > 0) {
nsAutoString val;
mText.AppendTo(val);
mutation.mNewAttrValue = do_GetAtom(val);
}
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);
mutation.mPrevAttrValue = oldValue;
if (aLength > 0) {
nsAutoString val;
mText.AppendTo(val);
mutation.mNewAttrValue = do_GetAtom(val);
}
mozAutoDocUpdateContentUnnest updateUnnest(document);
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);
}
}

Просмотреть файл

@ -2754,15 +2754,13 @@ nsGenericElement::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
if (nsContentUtils::HasMutationListeners(aKid,
NS_EVENT_BITS_MUTATION_NODEINSERTED, container)) {
mozAutoDocUpdateRemover updateRemover(aDocument);
if (nsContentUtils::IsSafeToRunScript()) {
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED);
mutation.mRelatedNode = do_QueryInterface(container);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED);
mutation.mRelatedNode = do_QueryInterface(container);
mozAutoSubtreeModified subtree(container->GetOwnerDoc(), container);
nsEventDispatcher::Dispatch(aKid, nsnull, &mutation);
}
mozAutoDocUpdateContentUnnest updateUnnest(aDocument);
mozAutoSubtreeModified subtree(container->GetOwnerDoc(), container);
nsEventDispatcher::Dispatch(aKid, nsnull, &mutation);
}
}
@ -2826,15 +2824,13 @@ nsGenericElement::doRemoveChildAt(PRUint32 aIndex, PRBool aNotify,
if (aNotify &&
nsContentUtils::HasMutationListeners(aKid,
NS_EVENT_BITS_MUTATION_NODEREMOVED, container)) {
mozAutoDocUpdateRemover updateRemover(aDocument);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEREMOVED);
mutation.mRelatedNode = do_QueryInterface(container);
if (nsContentUtils::IsSafeToRunScript()) {
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEREMOVED);
mutation.mRelatedNode = do_QueryInterface(container);
mozAutoDocUpdateContentUnnest updateUnnest(aDocument);
subtree.UpdateTarget(container->GetOwnerDoc(), container);
nsEventDispatcher::Dispatch(aKid, nsnull, &mutation);
}
subtree.UpdateTarget(container->GetOwnerDoc(), container);
nsEventDispatcher::Dispatch(aKid, nsnull, &mutation);
}
// Someone may have removed the kid or any of its siblings while that event
@ -3791,33 +3787,31 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
}
if (aFireMutation) {
mozAutoDocUpdateRemover updateRemover(document);
if (nsContentUtils::IsSafeToRunScript()) {
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
nsAutoString attrName;
aName->ToString(attrName);
nsCOMPtr<nsIDOMAttr> attrNode;
nsAutoString ns;
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
GetAttributeNodeNS(ns, attrName, getter_AddRefs(attrNode));
mutation.mRelatedNode = attrNode;
nsAutoString attrName;
aName->ToString(attrName);
nsCOMPtr<nsIDOMAttr> attrNode;
nsAutoString ns;
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
GetAttributeNodeNS(ns, attrName, getter_AddRefs(attrNode));
mutation.mRelatedNode = attrNode;
mutation.mAttrName = aName;
nsAutoString newValue;
GetAttr(aNamespaceID, aName, newValue);
if (!newValue.IsEmpty()) {
mutation.mNewAttrValue = do_GetAtom(newValue);
}
if (!aOldValue.IsEmpty()) {
mutation.mPrevAttrValue = do_GetAtom(aOldValue);
}
mutation.mAttrChange = modType;
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);
mutation.mAttrName = aName;
nsAutoString newValue;
GetAttr(aNamespaceID, aName, newValue);
if (!newValue.IsEmpty()) {
mutation.mNewAttrValue = do_GetAtom(newValue);
}
if (!aOldValue.IsEmpty()) {
mutation.mPrevAttrValue = do_GetAtom(aOldValue);
}
mutation.mAttrChange = modType;
mozAutoDocUpdateContentUnnest updateUnnest(document);
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);
}
if (aNamespaceID == kNameSpaceID_XMLEvents &&
@ -4050,25 +4044,23 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
}
if (hasMutationListeners) {
mozAutoDocUpdateRemover updateRemover(document);
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(static_cast<nsIContent *>(this));
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
if (nsContentUtils::IsSafeToRunScript()) {
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(static_cast<nsIContent *>(this));
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
mutation.mRelatedNode = attrNode;
mutation.mAttrName = aName;
mutation.mRelatedNode = attrNode;
mutation.mAttrName = aName;
nsAutoString value;
oldValue.ToString(value);
if (!value.IsEmpty())
mutation.mPrevAttrValue = do_GetAtom(value);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
nsAutoString value;
oldValue.ToString(value);
if (!value.IsEmpty())
mutation.mPrevAttrValue = do_GetAtom(value);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
mozAutoDocUpdateContentUnnest updateUnnest(document);
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);
}
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);
}
return AfterSetAttr(aNameSpaceID, aName, nsnull, aNotify);

Просмотреть файл

@ -1067,15 +1067,15 @@ private:
nsRefPtr<nsGenericElement> mContent;
};
class mozAutoDocUpdateRemover
class mozAutoDocUpdateContentUnnest
{
public:
mozAutoDocUpdateRemover(nsIDocument* aDocument)
: mDocument(aDocument)
mozAutoDocUpdateContentUnnest(nsIDocument* aDocument)
{
if (aDocument) {
mNestingLevel = aDocument->GetRemovableUpdateLevel();
aDocument->SetRemovableUpdateLevel(0);
NS_ASSERTION(aDocument->AllUpdatesAreContent(),
"There are non-content updates in progress");
mNestingLevel = aDocument->GetUpdateNestingLevel();
for (PRUint32 i = 0; i < mNestingLevel; ++i) {
nsContentUtils::RemoveScriptBlocker();
}
@ -1085,21 +1085,15 @@ public:
}
}
~mozAutoDocUpdateRemover()
~mozAutoDocUpdateContentUnnest()
{
NS_ASSERTION(mNestingLevel == 0 || mDocument,
"Count should be zero if there's no document");
if (mDocument) {
for (PRUint32 i = 0; i < mNestingLevel; ++i) {
nsContentUtils::AddScriptBlocker();
}
mDocument->SetRemovableUpdateLevel(mNestingLevel);
for (PRUint32 i = 0; i < mNestingLevel; ++i) {
nsContentUtils::AddScriptBlocker();
}
}
private:
PRUint32 mNestingLevel;
nsCOMPtr<nsIDocument> mDocument;
};
#endif /* nsGenericElement_h___ */

Просмотреть файл

@ -1435,22 +1435,20 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
}
if (hasMutationListeners) {
mozAutoDocUpdateRemover updateRemover(doc);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
if (nsContentUtils::IsSafeToRunScript()) {
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
mutation.mRelatedNode = attrNode;
mutation.mAttrName = aName;
mutation.mRelatedNode = attrNode;
mutation.mAttrName = aName;
if (!oldValue.IsEmpty())
mutation.mPrevAttrValue = do_GetAtom(oldValue);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
if (!oldValue.IsEmpty())
mutation.mPrevAttrValue = do_GetAtom(oldValue);
mutation.mAttrChange = nsIDOMMutationEvent::REMOVAL;
mozAutoDocUpdateContentUnnest updateUnnest(doc);
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
nsnull, &mutation);
}
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
nsnull, &mutation);
}
return NS_OK;