2016-01-06 05:04:06 +03:00
|
|
|
/* -*- 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 "AnimValuesStyleRule.h"
|
|
|
|
#include "nsRuleData.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(AnimValuesStyleRule, nsIStyleRule)
|
|
|
|
|
|
|
|
void
|
|
|
|
AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
nsStyleContext *contextParent = aRuleData->mStyleContext->GetParent();
|
|
|
|
if (contextParent && contextParent->HasPseudoElementData()) {
|
|
|
|
// Don't apply transitions or animations to things inside of
|
|
|
|
// pseudo-elements.
|
|
|
|
// FIXME (Bug 522599): Add tests for this.
|
|
|
|
|
|
|
|
// Prevent structs from being cached on the rule node since we're inside
|
|
|
|
// a pseudo-element, as we could determine cacheability differently
|
|
|
|
// when walking the rule tree for a style context that is not inside
|
|
|
|
// a pseudo-element. Note that nsRuleNode::GetStyle##name_ and GetStyleData
|
|
|
|
// will never look at cached structs when we're animating things inside
|
|
|
|
// a pseduo-element, so that we don't incorrectly return a struct that
|
|
|
|
// is only appropriate for non-pseudo-elements.
|
|
|
|
aRuleData->mConditions.SetUncacheable();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-05 08:26:44 +03:00
|
|
|
for (auto iter = mAnimationValues.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
nsCSSPropertyID property = static_cast<nsCSSPropertyID>(iter.Key());
|
2016-01-06 05:04:06 +03:00
|
|
|
if (aRuleData->mSIDs & nsCachedStyleData::GetBitForSID(
|
2016-10-05 08:26:44 +03:00
|
|
|
nsCSSProps::kSIDTable[property])) {
|
|
|
|
nsCSSValue *prop = aRuleData->ValueFor(property);
|
2016-01-06 05:04:06 +03:00
|
|
|
if (prop->GetUnit() == eCSSUnit_Null) {
|
2016-08-30 09:10:59 +03:00
|
|
|
DebugOnly<bool> ok =
|
2016-10-05 08:26:44 +03:00
|
|
|
StyleAnimationValue::UncomputeValue(property, iter.Data(),
|
2016-05-11 10:43:32 +03:00
|
|
|
*prop);
|
2016-01-06 05:04:06 +03:00
|
|
|
MOZ_ASSERT(ok, "could not store computed value");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AnimValuesStyleRule::MightMapInheritedStyleData()
|
|
|
|
{
|
|
|
|
return mStyleBits & NS_STYLE_INHERITED_STRUCT_MASK;
|
|
|
|
}
|
|
|
|
|
2016-08-16 08:29:21 +03:00
|
|
|
bool
|
2016-08-17 04:37:48 +03:00
|
|
|
AnimValuesStyleRule::GetDiscretelyAnimatedCSSValue(nsCSSPropertyID aProperty,
|
2016-08-16 08:29:21 +03:00
|
|
|
nsCSSValue* aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-05 08:26:44 +03:00
|
|
|
void
|
|
|
|
AnimValuesStyleRule::AddValue(nsCSSPropertyID aProperty,
|
|
|
|
const StyleAnimationValue &aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aProperty != eCSSProperty_UNKNOWN,
|
|
|
|
"Unexpected css property");
|
2017-02-12 02:30:22 +03:00
|
|
|
mAnimationValues.Put(aProperty, aValue);
|
2016-10-05 08:26:44 +03:00
|
|
|
mStyleBits |=
|
|
|
|
nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AnimValuesStyleRule::AddValue(nsCSSPropertyID aProperty,
|
|
|
|
StyleAnimationValue&& aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aProperty != eCSSProperty_UNKNOWN,
|
|
|
|
"Unexpected css property");
|
|
|
|
mAnimationValues.Put(aProperty, Move(aValue));
|
|
|
|
mStyleBits |=
|
|
|
|
nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]);
|
|
|
|
}
|
|
|
|
|
2016-12-04 02:07:39 +03:00
|
|
|
bool
|
|
|
|
AnimValuesStyleRule::GetValue(nsCSSPropertyID aProperty,
|
|
|
|
StyleAnimationValue& aValue) const
|
|
|
|
{
|
|
|
|
return mAnimationValues.Get(aProperty, &aValue);
|
|
|
|
}
|
|
|
|
|
2016-01-06 05:04:06 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
AnimValuesStyleRule::List(FILE* out, int32_t aIndent) const
|
|
|
|
{
|
|
|
|
nsAutoCString str;
|
|
|
|
for (int32_t index = aIndent; --index >= 0; ) {
|
|
|
|
str.AppendLiteral(" ");
|
|
|
|
}
|
|
|
|
str.AppendLiteral("[anim values] { ");
|
2016-10-05 08:26:44 +03:00
|
|
|
for (auto iter = mAnimationValues.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
nsCSSPropertyID property = static_cast<nsCSSPropertyID>(iter.Key());
|
|
|
|
str.Append(nsCSSProps::GetStringValue(property));
|
2016-01-06 05:04:06 +03:00
|
|
|
str.AppendLiteral(": ");
|
|
|
|
nsAutoString value;
|
2016-08-30 09:10:59 +03:00
|
|
|
Unused <<
|
2016-10-05 08:26:44 +03:00
|
|
|
StyleAnimationValue::UncomputeValue(property, iter.Data(), value);
|
2016-01-06 05:04:06 +03:00
|
|
|
AppendUTF16toUTF8(value, str);
|
|
|
|
str.AppendLiteral("; ");
|
|
|
|
}
|
|
|
|
str.AppendLiteral("}\n");
|
|
|
|
fprintf_stderr(out, "%s", str.get());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace mozilla
|