зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1232577 part 2 - Add a hashmap to ElementCompositor to track which (pseudo-) elements need to have their animation style rule updated; r=heycam
We will eventually use this in place of the various state flags stored on AnimationCollection (e.g. mStyleRuleRefreshTime, mStyleChanging, mHasPendingAnimationRestyle) as well as to do a more targetted update in FlushAnimations and AddStyleUpdatesTo.
This commit is contained in:
Родитель
641025e212
Коммит
a0f05d7d7e
|
@ -29,7 +29,23 @@ using mozilla::dom::KeyframeEffectReadOnly;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_0(EffectCompositor)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(EffectCompositor)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(EffectCompositor)
|
||||
for (auto& elementSet : tmp->mElementsToRestyle) {
|
||||
elementSet.Clear();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(EffectCompositor)
|
||||
for (auto& elementSet : tmp->mElementsToRestyle) {
|
||||
for (auto iter = elementSet.Iter(); !iter.Done(); iter.Next()) {
|
||||
CycleCollectionNoteChild(cb, iter.Key().mElement,
|
||||
"EffectCompositor::mElementsToRestyle[]",
|
||||
cb.Flags());
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(EffectCompositor, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(EffectCompositor, Release)
|
||||
|
|
|
@ -7,12 +7,15 @@
|
|||
#ifndef mozilla_EffectCompositor_h
|
||||
#define mozilla_EffectCompositor_h
|
||||
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Pair.h"
|
||||
#include "mozilla/PseudoElementHashEntry.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsCSSProperty.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsCSSPropertySet;
|
||||
|
@ -129,6 +132,15 @@ private:
|
|||
static nsPresContext* GetPresContext(dom::Element* aElement);
|
||||
|
||||
nsPresContext* mPresContext;
|
||||
|
||||
// Elements with a pending animation restyle. The associated bool value is
|
||||
// true if a pending animation restyle has also been dispatched. For
|
||||
// animations that can be throttled, we will add an entry to the hashtable to
|
||||
// indicate that the style rule on the element is out of date but without
|
||||
// posting a restyle to update it.
|
||||
EnumeratedArray<CascadeLevel, CascadeLevel(kCascadeLevelCount),
|
||||
nsDataHashtable<PseudoElementHashEntry, bool>>
|
||||
mElementsToRestyle;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_PseudoElementHashEntry_h
|
||||
#define mozilla_PseudoElementHashEntry_h
|
||||
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "PLDHashTable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct PseudoElementHashKey
|
||||
{
|
||||
dom::Element* mElement;
|
||||
nsCSSPseudoElements::Type mPseudoType;
|
||||
};
|
||||
|
||||
// A hash entry that uses a RefPtr<dom::Element>, nsCSSPseudoElements::Type pair
|
||||
class PseudoElementHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef PseudoElementHashKey KeyType;
|
||||
typedef const PseudoElementHashKey* KeyTypePointer;
|
||||
|
||||
explicit PseudoElementHashEntry(KeyTypePointer aKey)
|
||||
: mElement(aKey->mElement)
|
||||
, mPseudoType(aKey->mPseudoType) { }
|
||||
explicit PseudoElementHashEntry(const PseudoElementHashEntry& aCopy)=default;
|
||||
|
||||
~PseudoElementHashEntry() = default;
|
||||
|
||||
KeyType GetKey() const { return {mElement, mPseudoType}; }
|
||||
bool KeyEquals(KeyTypePointer aKey) const
|
||||
{
|
||||
return mElement == aKey->mElement &&
|
||||
mPseudoType == aKey->mPseudoType;
|
||||
}
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
||||
{
|
||||
if (!aKey)
|
||||
return 0;
|
||||
|
||||
return mozilla::HashGeneric(aKey->mElement, aKey->mPseudoType);
|
||||
}
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
|
||||
RefPtr<dom::Element> mElement;
|
||||
nsCSSPseudoElements::Type mPseudoType;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_PseudoElementHashEntry_h
|
|
@ -23,6 +23,7 @@ EXPORTS.mozilla += [
|
|||
'EffectCompositor.h',
|
||||
'EffectSet.h',
|
||||
'PendingAnimationTracker.h',
|
||||
'PseudoElementHashEntry.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
|
Загрузка…
Ссылка в новой задаче