Files
palemoon27/dom/animation/EffectSet.cpp
T
roytam1 0c05a61d5f import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1208584 - Silence unconstrained size warning by default. r=jfkthame (31f1771976)
- Bug 1248864 - Part 1: Move RestyleManager.h to EXPORTS.mozilla. r=dholbert (2ab8ae0d6a)
- Bug 1248864 - Part 2: Add skeleton ServoRestyleManager and a RestyleManagerHandle smart pointer. r=dholbert (8c9e032edc)
- Bug 1248864 - Part 3: Use RestyleManagerHandle instead of concrete restyle manager class. r=dholbert (ec282e77fa)
- Bug 1237825. Find the root scroll frame even if the root element doesn't have a primary frame. r=mstange (ed4f14ebd4)
- Bug 1237813. Refactor nsLayoutUtils::FindScrollableFrameFor to use GetScrollFrameFromContent. r=botond (403968c84c)
- Bug 1238777: Bail early from ComputeSnappedImageDrawingParameters if we're somehow drawing from a 0-sized subimage. r=tn (da3ccc27f0)
- Bug 1250377 - Part 1: Use MOZ_STYLO environment variable to switch on Servo-backed style system. r=bholley (4ce8d0bcf0)
- Bug 1250377 - Part 2: Stub out enough ServoStyleSet methods to be able to create one for a document. r=bholley (1ef3b5c843)
- Bug 1250377 - Part 3: Create a ServoStyleSet for HTML documents in content docshells. r=bholley (4ed1a5e6fc)
- Bug 1250790 - Don't try to add CSSStyleSheets from the style sheet service to a ServoStyleSet. r=bholley (f1291300d7)
- Bug 1247478: Rename FirstAdditionalAuthorSheet() to GetFirstAdditionalAuthorSheet(), since it can return null. r=heycam (cffd112172)
- Bug 1253007 - part 1 - use UniquePtr for RangePaintInfo in nsPresShell.cpp; r=dholbert (ad14ef91b7)
- Bug 1253007 - part 2 - pass a const& to PaintRangePaintInfo; rs=dholbert (9317f5b704)
- Bug 1171371 - On memory-pressure, remove any stale images from the visible images list. r=tn (9108fdc561)
- Bug 1251150. Add some crash annotations to try to track down a crash bug. r=dholbert (0b81d26d89)
- Bug 1257315 (Part 1) - Add a visualization of visibility tracking to the APZ minimap. r=botond,mattwoodrow (c15a5ce0f8)
- Bug 1257315 (Part 2) - Release old visible regions info when new info is available or a layers ID is no longer used. r=botond (3c5a1fb6e0)
- Rename PCompositor to PCompositorBridge. (bug 1258479 part 1, r=mattwoodrow) (77390ba817)
- Bug 1134385. Silk documentation. r=kats (23f43fa035)
- Bug 1134385 follow-up - fix link to image in documentation. DONTBUILD because NPOTB. r=me (68809f8347)
- Bug 1238743 - remove a bogus assertion in TextureClient.cpp. r=kats (6b10b546c5)
- Bug 1241484 - Null check mActor in WaitForCompositorRecycle. r=nical (95f848830f)
- Bug 1250117 - Fix b2g timeouts when gralloc is disabled. r=sotaro (2e67d92251)
- Bug 1250117 - Trivial b2g build fix. r=me (9fab71821d)
- Bug 1249273 - Enable BufferTextureHost to recycle a TextureSource that is not marked as owned. r=sotaro (f09b043af6)
- Bug 1250500 - Avoid copying BufferTextureHost when possible. r=sotaro (8f44549c6c)
- Bug 1248323: P1. Add support for YUV422 IOSurface. r=nical (e3eb53aa1c)
- Bug 1248323: P2. Add readback code for converting YUV422 MacIOSurfaces into RGB. r=nical (d93574fd13)
- Bug 1248323: P3. Add test for NV12/YUV422 readback. r=me (5373a2f839)
- Bug 1249273 - Lazily prepare TextureSources and recycle them when possible in ImageHost. r=sotaro (66bb273c84)
- Bug 1251910: Fix YUV422 IOSurface. r=mattwoodrow. (bfdbb2f60b)
2024-01-31 14:18:31 +08:00

202 lines
5.6 KiB
C++

/* -*- 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 "EffectSet.h"
#include "mozilla/dom/Element.h" // For Element
#include "mozilla/RestyleManagerHandle.h"
#include "mozilla/RestyleManagerHandleInlines.h"
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
#include "nsCycleCollectionNoteChild.h" // For CycleCollectionNoteChild
#include "nsPresContext.h"
#include "nsLayoutUtils.h"
namespace mozilla {
/* static */ void
EffectSet::PropertyDtor(void* aObject, nsIAtom* aPropertyName,
void* aPropertyValue, void* aData)
{
EffectSet* effectSet = static_cast<EffectSet*>(aPropertyValue);
#ifdef DEBUG
MOZ_ASSERT(!effectSet->mCalledPropertyDtor, "Should not call dtor twice");
effectSet->mCalledPropertyDtor = true;
#endif
delete effectSet;
}
void
EffectSet::Traverse(nsCycleCollectionTraversalCallback& aCallback)
{
for (auto iter = mEffects.Iter(); !iter.Done(); iter.Next()) {
CycleCollectionNoteChild(aCallback, iter.Get()->GetKey(),
"EffectSet::mEffects[]", aCallback.Flags());
}
}
/* static */ EffectSet*
EffectSet::GetEffectSet(dom::Element* aElement,
CSSPseudoElementType aPseudoType)
{
nsIAtom* propName = GetEffectSetPropertyAtom(aPseudoType);
return static_cast<EffectSet*>(aElement->GetProperty(propName));
}
/* static */ EffectSet*
EffectSet::GetEffectSet(const nsIFrame* aFrame)
{
nsIContent* content = aFrame->GetContent();
if (!content) {
return nullptr;
}
nsIAtom* propName;
if (aFrame->IsGeneratedContentFrame()) {
nsIFrame* parent = aFrame->GetParent();
if (parent->IsGeneratedContentFrame()) {
return nullptr;
}
nsIAtom* name = content->NodeInfo()->NameAtom();
if (name == nsGkAtoms::mozgeneratedcontentbefore) {
propName = nsGkAtoms::animationEffectsForBeforeProperty;
} else if (name == nsGkAtoms::mozgeneratedcontentafter) {
propName = nsGkAtoms::animationEffectsForAfterProperty;
} else {
return nullptr;
}
content = content->GetParent();
if (!content) {
return nullptr;
}
} else {
if (nsLayoutUtils::GetStyleFrame(content) != aFrame) {
// The effects associated with an element are for its primary frame.
return nullptr;
}
propName = nsGkAtoms::animationEffectsProperty;
}
if (!content->MayHaveAnimations()) {
return nullptr;
}
return static_cast<EffectSet*>(content->GetProperty(propName));
}
/* static */ EffectSet*
EffectSet::GetOrCreateEffectSet(dom::Element* aElement,
CSSPseudoElementType aPseudoType)
{
EffectSet* effectSet = GetEffectSet(aElement, aPseudoType);
if (effectSet) {
return effectSet;
}
nsIAtom* propName = GetEffectSetPropertyAtom(aPseudoType);
effectSet = new EffectSet();
nsresult rv = aElement->SetProperty(propName, effectSet,
&EffectSet::PropertyDtor, true);
if (NS_FAILED(rv)) {
NS_WARNING("SetProperty failed");
// The set must be destroyed via PropertyDtor, otherwise
// mCalledPropertyDtor assertion is triggered in destructor.
EffectSet::PropertyDtor(aElement, propName, effectSet, nullptr);
return nullptr;
}
aElement->SetMayHaveAnimations();
return effectSet;
}
/* static */ void
EffectSet::DestroyEffectSet(dom::Element* aElement,
CSSPseudoElementType aPseudoType)
{
nsIAtom* propName = GetEffectSetPropertyAtom(aPseudoType);
EffectSet* effectSet =
static_cast<EffectSet*>(aElement->GetProperty(propName));
if (!effectSet) {
return;
}
MOZ_ASSERT(!effectSet->IsBeingEnumerated(),
"Should not destroy an effect set while it is being enumerated");
effectSet = nullptr;
aElement->DeleteProperty(propName);
}
void
EffectSet::UpdateAnimationGeneration(nsPresContext* aPresContext)
{
MOZ_ASSERT(aPresContext->RestyleManager()->IsGecko(),
"stylo: Servo-backed style system should not be using "
"EffectSet");
mAnimationGeneration =
aPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration();
}
/* static */ nsIAtom**
EffectSet::GetEffectSetPropertyAtoms()
{
static nsIAtom* effectSetPropertyAtoms[] =
{
nsGkAtoms::animationEffectsProperty,
nsGkAtoms::animationEffectsForBeforeProperty,
nsGkAtoms::animationEffectsForAfterProperty,
nullptr
};
return effectSetPropertyAtoms;
}
/* static */ nsIAtom*
EffectSet::GetEffectSetPropertyAtom(CSSPseudoElementType aPseudoType)
{
switch (aPseudoType) {
case CSSPseudoElementType::NotPseudo:
return nsGkAtoms::animationEffectsProperty;
case CSSPseudoElementType::before:
return nsGkAtoms::animationEffectsForBeforeProperty;
case CSSPseudoElementType::after:
return nsGkAtoms::animationEffectsForAfterProperty;
default:
NS_NOTREACHED("Should not try to get animation effects for a pseudo "
"other that :before or :after");
return nullptr;
}
}
void
EffectSet::AddEffect(dom::KeyframeEffectReadOnly& aEffect)
{
if (mEffects.Contains(&aEffect)) {
return;
}
mEffects.PutEntry(&aEffect);
MarkCascadeNeedsUpdate();
}
void
EffectSet::RemoveEffect(dom::KeyframeEffectReadOnly& aEffect)
{
if (!mEffects.Contains(&aEffect)) {
return;
}
mEffects.RemoveEntry(&aEffect);
MarkCascadeNeedsUpdate();
}
} // namespace mozilla