зеркало из https://github.com/mozilla/pjs.git
Bug 560503. Don't check for mutation observer uniqueness; callers should handle that. r=sicking
This commit is contained in:
Родитель
db9dd1ff0d
Коммит
5d19cfdf12
|
@ -670,7 +670,8 @@ public:
|
|||
/**
|
||||
* Add a new observer of document change notifications. Whenever
|
||||
* content is changed, appended, inserted or removed the observers are
|
||||
* informed.
|
||||
* informed. An observer that is already observing the document must
|
||||
* not be added without being removed first.
|
||||
*/
|
||||
virtual void AddObserver(nsIDocumentObserver* aObserver) = 0;
|
||||
|
||||
|
|
|
@ -704,14 +704,43 @@ public:
|
|||
* observer, which means that it is the responsibility of the observer to
|
||||
* remove itself in case it dies before the node. If an observer is added
|
||||
* while observers are being notified, it may also be notified. In general,
|
||||
* adding observers while inside a notification is not a good idea.
|
||||
* adding observers while inside a notification is not a good idea. An
|
||||
* observer that is already observing the node must not be added without
|
||||
* being removed first.
|
||||
*/
|
||||
virtual void AddMutationObserver(nsIMutationObserver* aMutationObserver);
|
||||
void AddMutationObserver(nsIMutationObserver* aMutationObserver)
|
||||
{
|
||||
nsSlots* slots = GetSlots();
|
||||
if (slots) {
|
||||
NS_ASSERTION(slots->mMutationObservers.IndexOf(aMutationObserver) ==
|
||||
nsTArray_base::NoIndex,
|
||||
"Observer already in the list");
|
||||
slots->mMutationObservers.AppendElement(aMutationObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as above, but only adds the observer if its not observing
|
||||
* the node already.
|
||||
*/
|
||||
void AddMutationObserverUnlessExists(nsIMutationObserver* aMutationObserver)
|
||||
{
|
||||
nsSlots* slots = GetSlots();
|
||||
if (slots) {
|
||||
slots->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a mutation observer.
|
||||
*/
|
||||
virtual void RemoveMutationObserver(nsIMutationObserver* aMutationObserver);
|
||||
void RemoveMutationObserver(nsIMutationObserver* aMutationObserver)
|
||||
{
|
||||
nsSlots* slots = GetExistingSlots();
|
||||
if (slots) {
|
||||
slots->mMutationObservers.RemoveElement(aMutationObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones this node. This needs to be overriden by all node classes. aNodeInfo
|
||||
|
|
|
@ -3770,8 +3770,9 @@ nsDocument::ScriptLoader()
|
|||
void
|
||||
nsDocument::AddObserver(nsIDocumentObserver* aObserver)
|
||||
{
|
||||
// The array makes sure the observer isn't already in the list
|
||||
mObservers.AppendElementUnlessExists(aObserver);
|
||||
NS_ASSERTION(mObservers.IndexOf(aObserver) == nsTArray_base::NoIndex,
|
||||
"Observer already in the list");
|
||||
mObservers.AppendElement(aObserver);
|
||||
AddMutationObserver(aObserver);
|
||||
}
|
||||
|
||||
|
|
|
@ -283,24 +283,6 @@ nsINode::CreateSlots()
|
|||
return new nsSlots(mFlagsOrSlots);
|
||||
}
|
||||
|
||||
void
|
||||
nsINode::AddMutationObserver(nsIMutationObserver* aMutationObserver)
|
||||
{
|
||||
nsSlots* slots = GetSlots();
|
||||
if (slots) {
|
||||
slots->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsINode::RemoveMutationObserver(nsIMutationObserver* aMutationObserver)
|
||||
{
|
||||
nsSlots* slots = GetExistingSlots();
|
||||
if (slots) {
|
||||
slots->mMutationObservers.RemoveElement(aMutationObserver);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsINode::IsEditableInternal() const
|
||||
{
|
||||
|
|
|
@ -167,10 +167,9 @@ nsSVGOuterSVGFrame::Init(nsIContent* aContent,
|
|||
if (doc->GetRootElement() == mContent) {
|
||||
mIsRootContent = PR_TRUE;
|
||||
}
|
||||
// AddMutationObserver checks that the observer is not already added.
|
||||
// sSVGMutationObserver has the same lifetime as the document so does
|
||||
// not need to be removed
|
||||
doc->AddMutationObserver(&sSVGMutationObserver);
|
||||
doc->AddMutationObserverUnlessExists(&sSVGMutationObserver);
|
||||
}
|
||||
|
||||
SuspendRedraw(); // UnsuspendRedraw is in DidReflow
|
||||
|
|
Загрузка…
Ссылка в новой задаче