Bug 1433008 - Make AnimationEventInfo, InternalTransitionEvent and InternalAnimationEvent movable. r?masayuki
And disallow using copy constructor and copy assignment for the structs.
MozReview-Commit-ID: 7jSktlu1SqN
--- a/dom/animation/AnimationEventDispatcher.h
+++ b/dom/animation/AnimationEventDispatcher.h
@@ -68,23 +68,20 @@ struct AnimationEventInfo
event.mPropertyName =
NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
// XXX Looks like nobody initialize WidgetEvent::time
event.mElapsedTime = aElapsedTime;
event.mPseudoElement =
nsCSSPseudoElements::PseudoTypeAsString(aTarget.mPseudoType);
}
- // InternalAnimationEvent and InternalTransitionEvent don't support
- // copy-construction, so we need to ourselves in order to work with nsTArray.
- //
- // FIXME: Drop this copy constructor and copy assignment below once
- // WidgetEvent have move constructor and move assignment (bug 1433008).
- AnimationEventInfo(const AnimationEventInfo& aOther) = default;
- AnimationEventInfo& operator=(const AnimationEventInfo& aOther) = default;
+ AnimationEventInfo(const AnimationEventInfo& aOther) = delete;
+ AnimationEventInfo& operator=(const AnimationEventInfo& aOther) = delete;
+ AnimationEventInfo(AnimationEventInfo&& aOther) = default;
+ AnimationEventInfo& operator=(AnimationEventInfo&& aOther) = default;
WidgetEvent* AsWidgetEvent()
{
if (mEvent.is<InternalTransitionEvent>()) {
return &mEvent.as<InternalTransitionEvent>();
}
if (mEvent.is<InternalAnimationEvent>()) {
return &mEvent.as<InternalAnimationEvent>();
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -237,16 +237,21 @@ public:
}
InternalTransitionEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
, mElapsedTime(0.0)
{
}
+ InternalTransitionEvent(const InternalTransitionEvent& aOther) = delete;
+ InternalTransitionEvent& operator=(const InternalTransitionEvent& aOther) = delete;
+ InternalTransitionEvent(InternalTransitionEvent&& aOther) = default;
+ InternalTransitionEvent& operator=(InternalTransitionEvent&& aOther) = default;
+
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eTransitionEventClass,
"Duplicate() must be overridden by sub class");
InternalTransitionEvent* result =
new InternalTransitionEvent(false, mMessage);
result->AssignTransitionEventData(*this, true);
result->mFlags = mFlags;
@@ -281,16 +286,21 @@ public:
}
InternalAnimationEvent(bool aIsTrusted, EventMessage aMessage)
: WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
, mElapsedTime(0.0)
{
}
+ InternalAnimationEvent(const InternalAnimationEvent& aOther) = delete;
+ InternalAnimationEvent& operator=(const InternalAnimationEvent& aOther) = delete;
+ InternalAnimationEvent(InternalAnimationEvent&& aOther) = default;
+ InternalAnimationEvent& operator=(InternalAnimationEvent&& aOther) = default;
+
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eAnimationEventClass,
"Duplicate() must be overridden by sub class");
InternalAnimationEvent* result =
new InternalAnimationEvent(false, mMessage);
result->AssignAnimationEventData(*this, true);
result->mFlags = mFlags;