Bug 1123523 - Part 5: Record on a document whether it might have any nsIAnimationObservers registered. r=smaug

This commit is contained in:
Cameron McCormack 2015-03-14 16:34:40 +11:00
Родитель 9863e4114b
Коммит 3496ca27f3
4 изменённых файлов: 54 добавлений и 0 удалений

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

@ -2198,6 +2198,16 @@ public:
mMayHaveDOMMutationObservers = true;
}
bool MayHaveAnimationObservers()
{
return mMayHaveAnimationObservers;
}
void SetMayHaveAnimationObservers()
{
mMayHaveAnimationObservers = true;
}
bool IsInSyncOperation()
{
return mInSyncOperationCount != 0;
@ -2694,6 +2704,9 @@ protected:
// True if a DOMMutationObserver is perhaps attached to a node in the document.
bool mMayHaveDOMMutationObservers;
// True if an nsIAnimationObserver is perhaps attached to a node in the document.
bool mMayHaveAnimationObservers;
// True if a document has loaded Mixed Active Script (see nsMixedContentBlocker.cpp)
bool mHasMixedActiveContentLoaded;

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

@ -104,6 +104,7 @@
#include "nsGlobalWindow.h"
#include "nsDOMMutationObserver.h"
#include "GeometryUtils.h"
#include "nsIAnimationObserver.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -2748,3 +2749,18 @@ nsINode::GetScopeChainParent() const
{
return nullptr;
}
void
nsINode::AddAnimationObserver(nsIAnimationObserver* aAnimationObserver)
{
AddMutationObserver(aAnimationObserver);
OwnerDoc()->SetMayHaveAnimationObservers();
}
void
nsINode::AddAnimationObserverUnlessExists(
nsIAnimationObserver* aAnimationObserver)
{
AddMutationObserverUnlessExists(aAnimationObserver);
OwnerDoc()->SetMayHaveAnimationObservers();
}

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

@ -33,6 +33,7 @@ class nsAttrAndChildArray;
class nsChildContentList;
struct nsCSSSelectorList;
class nsDOMAttributeMap;
class nsIAnimationObserver;
class nsIContent;
class nsIDocument;
class nsIDOMElement;
@ -948,6 +949,9 @@ public:
* 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.
*
* For mutation observers that implement nsIAnimationObserver, use
* AddAnimationObserver instead.
*/
void AddMutationObserver(nsIMutationObserver* aMutationObserver)
{
@ -961,6 +965,9 @@ public:
/**
* Same as above, but only adds the observer if its not observing
* the node already.
*
* For mutation observers that implement nsIAnimationObserver, use
* AddAnimationObserverUnlessExists instead.
*/
void AddMutationObserverUnlessExists(nsIMutationObserver* aMutationObserver)
{
@ -968,6 +975,20 @@ public:
s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
}
/**
* Same as AddMutationObserver, but for nsIAnimationObservers. This
* additionally records on the document that animation observers have
* been registered, which is used to determine whether notifications
* must be fired when animations are added, removed or changed.
*/
void AddAnimationObserver(nsIAnimationObserver* aAnimationObserver);
/**
* Same as above, but only adds the observer if its not observing
* the node already.
*/
void AddAnimationObserverUnlessExists(nsIAnimationObserver* aAnimationObserver);
/**
* Removes a mutation observer.
*/

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

@ -457,6 +457,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
newDoc->SetMayHaveDOMMutationObservers();
}
if (oldDoc != newDoc && oldDoc->MayHaveAnimationObservers()) {
newDoc->SetMayHaveAnimationObservers();
}
if (elem) {
elem->RecompileScriptEventListeners();
}