From 467ed67c743f14397167e4447018baf39f447e02 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Wed, 21 Feb 2018 10:13:13 +0900 Subject: [PATCH] Bug 1388557 - Call RequestRestyle(Layer) in the case where we attach orphaned animating element to the document. r=birtles MozReview-Commit-ID: IIcyYFROqDx --HG-- extra : rebase_source : f096635d400528660d5243d2884d125e7b623db2 --- dom/animation/test/mozilla/file_restyles.html | 17 +++++------------ dom/base/Element.cpp | 13 +++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dom/animation/test/mozilla/file_restyles.html b/dom/animation/test/mozilla/file_restyles.html index 80887ba742fb..b68c5ae00b77 100644 --- a/dom/animation/test/mozilla/file_restyles.html +++ b/dom/animation/test/mozilla/file_restyles.html @@ -1288,21 +1288,14 @@ waitForAllPaints(() => { // re-attaching which leads to invoking a SequentialTask for // CascadeResults which ends up calling RequestRestyle(Standard). As a // result, the animation is restyled during a second animation restyle in - // the first frame. If we fix the behavior when we attach an orphaned - // element with script animations to a document so that it requests a - // layer restyle (bug 1388557) before fixing important_rules_change in - // compute_style() so that it no longer dispatches a needless standard - // restyle (bug 1388560), we should add a test case that fails if we - // continue to unnecessarily request a standard restyle. + // the first frame. + todo_is(markers.length, 1, + 'Bug 1388560 We should observe one restyle in the first frame ' + + 'right after re-attaching to the document'); + } else { is(markers.length, 1, 'We should observe one restyle in the first frame right after ' + 're-attaching to the document'); - } else { - // Bug 1388557: We should call RequestRestyle(Layer) when an element which - // has running script animations is attached to a document. - todo_is(markers.length, 1, - 'Bug 1388557 We should observe one restyle in the first frame ' + - 'right after re-attaching to the document'); } markers = await observeStyling(5); is(markers.length, 5, diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 247bbd72d99c..57514b1deabc 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1849,6 +1849,19 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent, } MOZ_ASSERT(parent); } + + if (MayHaveAnimations() && + (pseudoType == CSSPseudoElementType::NotPseudo || + pseudoType == CSSPseudoElementType::before || + pseudoType == CSSPseudoElementType::after) && + EffectSet::GetEffectSet(this, pseudoType)) { + if (nsPresContext* presContext = aDocument->GetPresContext()) { + presContext->EffectCompositor()-> + RequestRestyle(this, pseudoType, + EffectCompositor::RestyleType::Standard, + EffectCompositor::CascadeLevel::Animations); + } + } } // XXXbz script execution during binding can trigger some of these