Bug 1699890 - Restrict background-color animations on canvas frame or on <body> element not to run on the compositor in KeyframeEffect::IsMatchForCompositor. r=boris

So that now EffectCompositor::HasAnimationsForCompositor doesn't return true
for such cases, thus we will not accidentally try to generate
nsDisplayBackgroundColor display item for such animations (bug 1699890#c21)
and we will not generate nsChangeHint_RepaintFrame (bug 1701547) either.

Differential Revision: https://phabricator.services.mozilla.com/D115774
This commit is contained in:
Hiroyuki Ikezoe 2021-05-26 00:17:39 +00:00
parent 5b5089618f
commit e63d42d765
4 changed files with 25 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include "nsCSSPropertyIDSet.h"
#include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
#include "nsCSSPseudoElements.h" // For PseudoStyleType
#include "nsCSSRendering.h" // For IsCanvasFrame
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIFrame.h"
#include "nsIFrameInlines.h"
@ -2056,6 +2057,15 @@ KeyframeEffect::MatchForCompositor KeyframeEffect::IsMatchForCompositor(
if (!StaticPrefs::gfx_omta_background_color()) {
return KeyframeEffect::MatchForCompositor::No;
}
// We don't yet support off-main-thread background-color animations on
// canvas frame or on <body> which genarate nsDisplayCanvasBackgroundColor
// or nsDisplaySolidColor display item.
if (nsCSSRendering::IsCanvasFrame(aFrame) ||
(aFrame->GetContent() &&
aFrame->GetContent()->IsHTMLElement(nsGkAtoms::body))) {
return KeyframeEffect::MatchForCompositor::No;
}
}
// We can't run this background color animation on the compositor if there

View File

@ -64,6 +64,7 @@ UNIFIED_SOURCES += [
LOCAL_INCLUDES += [
"/dom/base",
"/layout/base",
"/layout/painting",
"/layout/style",
]

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<style>
@keyframes anim {
from { background-color: rgba(0, 0, 0, 0); }
to { background-color: rgba(255, 0, 0, 255); }
}
body {
animation: anim 100s;
width: 100vw;
height: 100vh;
}
</style>

View File

@ -55,3 +55,4 @@ pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.getAnimations
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.implicit-keyframes.enabled,true) load 1633486.html
pref(layout.animation.prerender.partial,true) load 1656419.html
pref(layout.css.step-position-jump.enabled,true) load 1706157.html
pref(gfx.omta.background-color,true) load 1699890.html