WillChangeData.cpp [plain text]
#include "config.h"
#include "WillChangeData.h"
namespace WebCore {
bool WillChangeData::operator==(const WillChangeData& other) const
{
return m_animatableFeatures == other.m_animatableFeatures;
}
bool WillChangeData::containsScrollPosition() const
{
for (const auto& feature : m_animatableFeatures) {
if (feature.feature() == ScrollPosition)
return true;
}
return false;
}
bool WillChangeData::containsContents() const
{
for (const auto& feature : m_animatableFeatures) {
if (feature.feature() == Contents)
return true;
}
return false;
}
bool WillChangeData::containsProperty(CSSPropertyID property) const
{
for (const auto& feature : m_animatableFeatures) {
if (feature.property() == property)
return true;
}
return false;
}
static bool propertyCreatesStackingContext(CSSPropertyID property)
{
switch (property) {
case CSSPropertyPerspective:
case CSSPropertyTransform:
case CSSPropertyTransformStyle:
case CSSPropertyWebkitTransformStyle:
case CSSPropertyClipPath:
case CSSPropertyWebkitClipPath:
case CSSPropertyMask:
case CSSPropertyOpacity:
case CSSPropertyPosition:
case CSSPropertyZIndex:
case CSSPropertyWebkitBoxReflect:
#if ENABLE(CSS_COMPOSITING)
case CSSPropertyMixBlendMode:
case CSSPropertyIsolation:
#endif
case CSSPropertyFilter:
#if ENABLE(FILTERS_LEVEL_2)
case CSSPropertyWebkitBackdropFilter:
#endif
case CSSPropertyWebkitMask:
case CSSPropertyWebkitMaskImage:
case CSSPropertyWebkitMaskBoxImage:
#if ENABLE(CSS_REGIONS)
case CSSPropertyWebkitFlowFrom:
#endif
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
case CSSPropertyWebkitOverflowScrolling:
#endif
return true;
default:
return false;
}
}
static bool propertyTriggersCompositing(CSSPropertyID property)
{
switch (property) {
case CSSPropertyOpacity:
case CSSPropertyFilter:
#if ENABLE(FILTERS_LEVEL_2)
case CSSPropertyWebkitBackdropFilter:
#endif
return true;
default:
return false;
}
}
static bool propertyTriggersCompositingOnBoxesOnly(CSSPropertyID property)
{
switch (property) {
case CSSPropertyTransform:
return true;
default:
return false;
}
}
void WillChangeData::addFeature(Feature feature, CSSPropertyID propertyID)
{
ASSERT(feature == Property || propertyID == CSSPropertyInvalid);
m_animatableFeatures.append(AnimatableFeature(feature, propertyID));
m_canCreateStackingContext |= propertyCreatesStackingContext(propertyID);
m_canTriggerCompositingOnInline |= propertyTriggersCompositing(propertyID);
m_canTriggerCompositing |= m_canTriggerCompositingOnInline | propertyTriggersCompositingOnBoxesOnly(propertyID);
}
WillChangeData::FeaturePropertyPair WillChangeData::featureAt(size_t index) const
{
if (index >= m_animatableFeatures.size())
return FeaturePropertyPair(Invalid, CSSPropertyInvalid);
return m_animatableFeatures[index].featurePropertyPair();
}
}