Commit 0da9ad49 authored by haraken@chromium.org's avatar haraken@chromium.org

Use HeapHashCountedSet for AnimationPlayerCountedSet

In r172647, I changed the AnimationPlayerCountedSet from a HashCountedSet to a HashMap, because at that time Oilpan didn't support a HashCountedSet. Now that Oilpan supports a HashCountedSet, this CL changes it back to a HashCountedSet again.

BUG=340522

Review URL: https://codereview.chromium.org/425903003

git-svn-id: svn://svn.chromium.org/blink/trunk@179097 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0acf63f8
...@@ -44,21 +44,6 @@ ActiveAnimations::~ActiveAnimations() ...@@ -44,21 +44,6 @@ ActiveAnimations::~ActiveAnimations()
#endif #endif
} }
void ActiveAnimations::addPlayer(AnimationPlayer* player)
{
++m_players.add(player, 0).storedValue->value;
}
void ActiveAnimations::removePlayer(AnimationPlayer* player)
{
AnimationPlayerCountedSet::iterator it = m_players.find(player);
ASSERT(it != m_players.end());
ASSERT(it->value > 0);
--it->value;
if (!it->value)
m_players.remove(it);
}
void ActiveAnimations::updateAnimationFlags(RenderStyle& style) void ActiveAnimations::updateAnimationFlags(RenderStyle& style)
{ {
for (AnimationPlayerCountedSet::const_iterator it = m_players.begin(); it != m_players.end(); ++it) { for (AnimationPlayerCountedSet::const_iterator it = m_players.begin(); it != m_players.end(); ++it) {
......
...@@ -44,7 +44,7 @@ class CSSAnimations; ...@@ -44,7 +44,7 @@ class CSSAnimations;
class RenderObject; class RenderObject;
class Element; class Element;
typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<AnimationPlayer>, int> AnimationPlayerCountedSet; typedef WillBeHeapHashCountedSet<RawPtrWillBeWeakMember<AnimationPlayer> > AnimationPlayerCountedSet;
class ActiveAnimations : public NoBaseWillBeGarbageCollectedFinalized<ActiveAnimations> { class ActiveAnimations : public NoBaseWillBeGarbageCollectedFinalized<ActiveAnimations> {
WTF_MAKE_NONCOPYABLE(ActiveAnimations); WTF_MAKE_NONCOPYABLE(ActiveAnimations);
...@@ -67,9 +67,7 @@ public: ...@@ -67,9 +67,7 @@ public:
const CSSAnimations& cssAnimations() const { return m_cssAnimations; } const CSSAnimations& cssAnimations() const { return m_cssAnimations; }
// AnimationPlayers which have animations targeting this element. // AnimationPlayers which have animations targeting this element.
const AnimationPlayerCountedSet& players() const { return m_players; } AnimationPlayerCountedSet& players() { return m_players; }
void addPlayer(AnimationPlayer*);
void removePlayer(AnimationPlayer*);
#if ENABLE(OILPAN) #if ENABLE(OILPAN)
bool isEmpty() const { return m_defaultStack.isEmpty() && m_cssAnimations.isEmpty(); } bool isEmpty() const { return m_defaultStack.isEmpty() && m_cssAnimations.isEmpty(); }
......
...@@ -112,7 +112,7 @@ Animation::~Animation() ...@@ -112,7 +112,7 @@ Animation::~Animation()
void Animation::attach(AnimationPlayer* player) void Animation::attach(AnimationPlayer* player)
{ {
if (m_target) { if (m_target) {
m_target->ensureActiveAnimations().addPlayer(player); m_target->ensureActiveAnimations().players().add(player);
m_target->setNeedsAnimationStyleRecalc(); m_target->setNeedsAnimationStyleRecalc();
} }
AnimationNode::attach(player); AnimationNode::attach(player);
...@@ -121,7 +121,7 @@ void Animation::attach(AnimationPlayer* player) ...@@ -121,7 +121,7 @@ void Animation::attach(AnimationPlayer* player)
void Animation::detach() void Animation::detach()
{ {
if (m_target) if (m_target)
m_target->activeAnimations()->removePlayer(player()); m_target->activeAnimations()->players().remove(player());
if (m_sampledEffect) if (m_sampledEffect)
clearEffects(); clearEffects();
AnimationNode::detach(); AnimationNode::detach();
......
...@@ -718,7 +718,7 @@ TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) ...@@ -718,7 +718,7 @@ TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers)
RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer(animation.get()); RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer(animation.get());
player->setStartTime(0); player->setStartTime(0);
timeline->serviceAnimations(TimingUpdateForAnimationFrame); timeline->serviceAnimations(TimingUpdateForAnimationFrame);
EXPECT_EQ(1, element->activeAnimations()->players().find(player.get())->value); EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->value);
player.release(); player.release();
Heap::collectAllGarbage(); Heap::collectAllGarbage();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment