mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1226118 part 5 - Move LogAsyncAnimationFailure to AnimationUtils; r=dholbert
This patch also moves AnimationUtils out of the dom namespace since it seems unnecessary. We typically only put actual DOM interfaces in the dom namespace.
This commit is contained in:
parent
7f1672cff8
commit
fd98de719c
36
dom/animation/AnimationUtils.cpp
Normal file
36
dom/animation/AnimationUtils.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#include "AnimationUtils.h"
|
||||
|
||||
#include "nsDebug.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/* static */ void
|
||||
AnimationUtils::LogAsyncAnimationFailure(nsCString& aMessage,
|
||||
const nsIContent* aContent)
|
||||
{
|
||||
if (aContent) {
|
||||
aMessage.AppendLiteral(" [");
|
||||
aMessage.Append(nsAtomCString(aContent->NodeInfo()->NameAtom()));
|
||||
|
||||
nsIAtom* id = aContent->GetID();
|
||||
if (id) {
|
||||
aMessage.AppendLiteral(" with id '");
|
||||
aMessage.Append(nsAtomCString(aContent->GetID()));
|
||||
aMessage.Append('\'');
|
||||
}
|
||||
aMessage.Append(']');
|
||||
}
|
||||
aMessage.Append('\n');
|
||||
printf_stderr("%s", aMessage.get());
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
@ -9,17 +9,19 @@
|
||||
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AnimationUtils
|
||||
{
|
||||
public:
|
||||
static Nullable<double>
|
||||
TimeDurationToDouble(const Nullable<TimeDuration>& aTime)
|
||||
static dom::Nullable<double>
|
||||
TimeDurationToDouble(const dom::Nullable<TimeDuration>& aTime)
|
||||
{
|
||||
Nullable<double> result;
|
||||
dom::Nullable<double> result;
|
||||
|
||||
if (!aTime.IsNull()) {
|
||||
result.SetValue(aTime.Value().ToMilliseconds());
|
||||
@ -28,10 +30,10 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static Nullable<TimeDuration>
|
||||
DoubleToTimeDuration(const Nullable<double>& aTime)
|
||||
static dom::Nullable<TimeDuration>
|
||||
DoubleToTimeDuration(const dom::Nullable<double>& aTime)
|
||||
{
|
||||
Nullable<TimeDuration> result;
|
||||
dom::Nullable<TimeDuration> result;
|
||||
|
||||
if (!aTime.IsNull()) {
|
||||
result.SetValue(TimeDuration::FromMilliseconds(aTime.Value()));
|
||||
@ -39,9 +41,11 @@ public:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void LogAsyncAnimationFailure(nsCString& aMessage,
|
||||
const nsIContent* aContent = nullptr);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h"
|
||||
#include "mozilla/dom/KeyframeEffectBinding.h"
|
||||
#include "mozilla/dom/PropertyIndexedKeyframesBinding.h"
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
|
||||
#include "mozilla/StyleAnimationValue.h"
|
||||
@ -55,7 +56,7 @@ GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
|
||||
aRetVal.mActiveDuration = aComputedTiming.mActiveDuration.ToMilliseconds();
|
||||
aRetVal.mEndTime
|
||||
= std::max(aRetVal.mDelay + aRetVal.mActiveDuration + aRetVal.mEndDelay, 0.0);
|
||||
aRetVal.mLocalTime = dom::AnimationUtils::TimeDurationToDouble(aLocalTime);
|
||||
aRetVal.mLocalTime = AnimationUtils::TimeDurationToDouble(aLocalTime);
|
||||
aRetVal.mProgress = aComputedTiming.mProgress;
|
||||
if (!aRetVal.mProgress.IsNull()) {
|
||||
// Convert the returned currentIteration into Infinity if we set
|
||||
@ -1990,7 +1991,7 @@ KeyframeEffectReadOnly::CanAnimateTransformOnCompositor(
|
||||
nsCString message;
|
||||
message.AppendLiteral("Gecko bug: Async animation of 'preserve-3d' "
|
||||
"transforms is not supported. See bug 779598");
|
||||
AnimationCollection::LogAsyncAnimationFailure(message, aContent);
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, aContent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2004,7 +2005,7 @@ KeyframeEffectReadOnly::CanAnimateTransformOnCompositor(
|
||||
message.AppendLiteral("Gecko bug: Async animation of "
|
||||
"'backface-visibility: hidden' transforms is not supported."
|
||||
" See bug 1186204.");
|
||||
AnimationCollection::LogAsyncAnimationFailure(message, aContent);
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, aContent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2013,7 +2014,7 @@ KeyframeEffectReadOnly::CanAnimateTransformOnCompositor(
|
||||
nsCString message;
|
||||
message.AppendLiteral("Gecko bug: Async 'transform' animations of "
|
||||
"aFrames with SVG transforms is not supported. See bug 779599");
|
||||
AnimationCollection::LogAsyncAnimationFailure(message, aContent);
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, aContent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2034,8 +2035,7 @@ KeyframeEffectReadOnly::CanAnimatePropertyOnCompositor(
|
||||
message.AppendLiteral("Performance warning: Async animation of "
|
||||
"'transform' or 'opacity' not possible due to animation of geometric"
|
||||
"properties on the same element");
|
||||
AnimationCollection::LogAsyncAnimationFailure(message,
|
||||
aFrame->GetContent());
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, aFrame->GetContent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ UNIFIED_SOURCES += [
|
||||
'Animation.cpp',
|
||||
'AnimationEffectReadOnly.cpp',
|
||||
'AnimationTimeline.cpp',
|
||||
'AnimationUtils.cpp',
|
||||
'ComputedTimingFunction.cpp',
|
||||
'DocumentTimeline.cpp',
|
||||
'EffectSet.cpp',
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "ImageContainer.h"
|
||||
#include "nsCanvasFrame.h"
|
||||
#include "StickyScrollContainer.h"
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/PendingAnimationTracker.h"
|
||||
@ -5398,8 +5399,7 @@ nsDisplayOpacity::CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder)
|
||||
if (nsLayoutUtils::IsAnimationLoggingEnabled()) {
|
||||
nsCString message;
|
||||
message.AppendLiteral("Performance warning: Async animation disabled because frame was not marked active for opacity animation");
|
||||
AnimationCollection::LogAsyncAnimationFailure(message,
|
||||
Frame()->GetContent());
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, Frame()->GetContent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -5450,8 +5450,7 @@ nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBui
|
||||
if (aLogAnimations) {
|
||||
nsCString message;
|
||||
message.AppendLiteral("Performance warning: Async animation disabled because frame was not marked active for transform animation");
|
||||
AnimationCollection::LogAsyncAnimationFailure(message,
|
||||
aFrame->GetContent());
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, aFrame->GetContent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -5490,8 +5489,7 @@ nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBui
|
||||
message.AppendLiteral(") is larger than the max allowable value (");
|
||||
message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(maxInAppUnits));
|
||||
message.Append(')');
|
||||
AnimationCollection::LogAsyncAnimationFailure(message,
|
||||
aFrame->GetContent());
|
||||
AnimationUtils::LogAsyncAnimationFailure(message, aFrame->GetContent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "LayerAnimationInfo.h" // For LayerAnimationInfo::sRecords
|
||||
#include "FrameLayerBuilder.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/KeyframeEffect.h"
|
||||
@ -438,7 +439,7 @@ AnimationCollection::CanPerformOnCompositorThread(const nsIFrame* aFrame) const
|
||||
if (nsLayoutUtils::IsAnimationLoggingEnabled()) {
|
||||
nsCString message;
|
||||
message.AppendLiteral("Performance warning: Async animations are disabled");
|
||||
LogAsyncAnimationFailure(message);
|
||||
AnimationUtils::LogAsyncAnimationFailure(message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -524,26 +525,6 @@ AnimationCollection::GetElementToRestyle() const
|
||||
return pseudoFrame->GetContent()->AsElement();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AnimationCollection::LogAsyncAnimationFailure(nsCString& aMessage,
|
||||
const nsIContent* aContent)
|
||||
{
|
||||
if (aContent) {
|
||||
aMessage.AppendLiteral(" [");
|
||||
aMessage.Append(nsAtomCString(aContent->NodeInfo()->NameAtom()));
|
||||
|
||||
nsIAtom* id = aContent->GetID();
|
||||
if (id) {
|
||||
aMessage.AppendLiteral(" with id '");
|
||||
aMessage.Append(nsAtomCString(aContent->GetID()));
|
||||
aMessage.Append('\'');
|
||||
}
|
||||
aMessage.Append(']');
|
||||
}
|
||||
aMessage.Append('\n');
|
||||
printf_stderr("%s", aMessage.get());
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
AnimationCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
||||
void *aPropertyValue, void *aData)
|
||||
|
@ -335,9 +335,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void LogAsyncAnimationFailure(nsCString& aMessage,
|
||||
const nsIContent* aContent = nullptr);
|
||||
|
||||
dom::Element *mElement;
|
||||
|
||||
// the atom we use in mElement's prop table (must be a static atom,
|
||||
|
Loading…
Reference in New Issue
Block a user