Bug 1249219 - Part 3: Replace Pair<Element*, CSSPseudoElementType> with NonOwningAnimationTarget. r=birtles

--HG--
extra : rebase_source : 35e69a293cdb7a25ce579dbb453289ed3521e7e2
This commit is contained in:
Boris Chiou 2016-03-21 16:49:50 +08:00
Родитель 4f53d19ab1
Коммит efe45f15d3
3 изменённых файлов: 12 добавлений и 14 удалений

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

@ -19,7 +19,6 @@
#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
#include "nsCSSPropertySet.h"
#include "nsCSSProps.h"
#include "nsCSSPseudoElements.h"
#include "nsIPresShell.h"
#include "nsLayoutUtils.h"
#include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
@ -83,11 +82,11 @@ FindAnimationsForCompositor(const nsIFrame* aFrame,
// Those cases are probably not important but just to be safe, let's make
// sure the cascade is up to date since if it *is* up to date, this is
// basically a no-op.
Maybe<Pair<dom::Element*, CSSPseudoElementType>> pseudoElement =
Maybe<NonOwningAnimationTarget> pseudoElement =
EffectCompositor::GetAnimationElementAndPseudoForFrame(aFrame);
if (pseudoElement) {
EffectCompositor::MaybeUpdateCascadeResults(pseudoElement->first(),
pseudoElement->second(),
EffectCompositor::MaybeUpdateCascadeResults(pseudoElement->mElement,
pseudoElement->mPseudoType,
aFrame->StyleContext());
}
@ -498,11 +497,11 @@ EffectCompositor::UpdateCascadeResults(Element* aElement,
UpdateCascadeResults(*effects, aElement, aPseudoType, aStyleContext);
}
/* static */ Maybe<Pair<Element*, CSSPseudoElementType>>
/* static */ Maybe<NonOwningAnimationTarget>
EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
{
// Always return the same object to benefit from return-value optimization.
Maybe<Pair<Element*, CSSPseudoElementType>> result;
Maybe<NonOwningAnimationTarget> result;
nsIContent* content = aFrame->GetContent();
if (!content) {
@ -539,7 +538,7 @@ EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
return result;
}
result = Some(MakePair(content->AsElement(), pseudoType));
result.emplace(content->AsElement(), pseudoType);
return result;
}

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

@ -10,7 +10,7 @@
#include "mozilla/EnumeratedArray.h"
#include "mozilla/Maybe.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/Pair.h"
#include "mozilla/NonOwningAnimationTarget.h"
#include "mozilla/PseudoElementHashEntry.h"
#include "mozilla/RefPtr.h"
#include "nsCSSProperty.h"
@ -29,7 +29,6 @@ namespace mozilla {
class EffectSet;
class RestyleTracker;
enum class CSSPseudoElementType : uint8_t;
struct AnimationPerformanceWarning;
namespace dom {
@ -185,7 +184,7 @@ public:
// Returns an empty result when a suitable element cannot be found including
// when the frame represents a pseudo-element on which we do not support
// animations.
static Maybe<Pair<dom::Element*, CSSPseudoElementType>>
static Maybe<NonOwningAnimationTarget>
GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame);
// Associates a performance warning with effects on |aFrame| that animates

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

@ -63,18 +63,18 @@ template <class AnimationType>
AnimationCollection<AnimationType>::GetAnimationCollection(
const nsIFrame* aFrame)
{
Maybe<Pair<dom::Element*, CSSPseudoElementType>> pseudoElement =
Maybe<NonOwningAnimationTarget> pseudoElement =
EffectCompositor::GetAnimationElementAndPseudoForFrame(aFrame);
if (!pseudoElement) {
return nullptr;
}
if (!pseudoElement->first()->MayHaveAnimations()) {
if (!pseudoElement->mElement->MayHaveAnimations()) {
return nullptr;
}
return GetAnimationCollection(pseudoElement->first(),
pseudoElement->second());
return GetAnimationCollection(pseudoElement->mElement,
pseudoElement->mPseudoType);
}
template <class AnimationType>