From cdde6f6108e8d6d5ab574297b7c114345da52e83 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 8 Jun 2017 10:22:25 +0900 Subject: [PATCH] Bug 1368889 - Post animation restyle hint againt pseudo element instead of its parent. r=birtles To traverse pseudo elements in animation-only restyle, the pseudo element itself needs the animation-only dirty bit. MozReview-Commit-ID: 11RfVqnPXfJ --HG-- extra : rebase_source : d048c9a053c03bf3fef46fcbfd9cbd5f60204e1d --- dom/animation/EffectCompositor.cpp | 2 ++ dom/animation/EffectCompositor.h | 13 +++++++++---- dom/smil/nsSMILAnimationController.cpp | 1 + layout/base/ServoRestyleManager.cpp | 18 +++++++++++++++--- layout/base/ServoRestyleManager.h | 1 + layout/style/test/stylo-failures.md | 1 - 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dom/animation/EffectCompositor.cpp b/dom/animation/EffectCompositor.cpp index 99bf1e706b9d..020a580752d9 100644 --- a/dom/animation/EffectCompositor.cpp +++ b/dom/animation/EffectCompositor.cpp @@ -1042,6 +1042,7 @@ EffectCompositor::PreTraverseInSubtree(Element* aRoot, // middle of the servo traversal. mPresContext->RestyleManager()->AsServo()-> PostRestyleEventForAnimations(target.mElement, + target.mPseudoType, cascadeLevel == CascadeLevel::Transitions ? eRestyle_CSSTransitions : eRestyle_CSSAnimations); @@ -1108,6 +1109,7 @@ EffectCompositor::PreTraverse(dom::Element* aElement, mPresContext->RestyleManager()->AsServo()-> PostRestyleEventForAnimations(aElement, + aPseudoType, cascadeLevel == CascadeLevel::Transitions ? eRestyle_CSSTransitions : eRestyle_CSSAnimations); diff --git a/dom/animation/EffectCompositor.h b/dom/animation/EffectCompositor.h index ff35a79b2b88..5a93bec0b448 100644 --- a/dom/animation/EffectCompositor.h +++ b/dom/animation/EffectCompositor.h @@ -249,6 +249,15 @@ public: bool PreTraverseInSubtree(dom::Element* aElement, AnimationRestyleType aRestyleType); + // Returns the target element for restyling. + // + // If |aPseudoType| is ::after or ::before, returns the generated content + // element of which |aElement| is the parent. If |aPseudoType| is any other + // pseudo type (other thant CSSPseudoElementType::NotPseudo) returns nullptr. + // Otherwise, returns |aElement|. + static dom::Element* GetElementToRestyle(dom::Element* aElement, + CSSPseudoElementType aPseudoType); + private: ~EffectCompositor() = default; @@ -258,10 +267,6 @@ private: CSSPseudoElementType aPseudoType, CascadeLevel aCascadeLevel); - static dom::Element* GetElementToRestyle(dom::Element* aElement, - CSSPseudoElementType - aPseudoType); - // Get the properties in |aEffectSet| that we are able to animate on the // compositor but which are also specified at a higher level in the cascade // than the animations level. diff --git a/dom/smil/nsSMILAnimationController.cpp b/dom/smil/nsSMILAnimationController.cpp index 773658b83c1f..f8f4fc4d5bce 100644 --- a/dom/smil/nsSMILAnimationController.cpp +++ b/dom/smil/nsSMILAnimationController.cpp @@ -767,6 +767,7 @@ nsSMILAnimationController::PreTraverseInSubtree(Element* aRoot) context->RestyleManager()->AsServo()-> PostRestyleEventForAnimations(key.mElement, + CSSPseudoElementType::NotPseudo, eRestyle_StyleAttribute_Animations); foundElementsNeedingRestyle = true; diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp index 8edb8fbc00b5..b6a4626f830e 100644 --- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -74,10 +74,22 @@ ServoRestyleManager::PostRestyleEventForCSSRuleChanges() } /* static */ void -ServoRestyleManager::PostRestyleEventForAnimations(Element* aElement, - nsRestyleHint aRestyleHint) +ServoRestyleManager::PostRestyleEventForAnimations( + Element* aElement, + CSSPseudoElementType aPseudoType, + nsRestyleHint aRestyleHint) { - Servo_NoteExplicitHints(aElement, aRestyleHint, nsChangeHint(0)); + Element* elementToRestyle = + EffectCompositor::GetElementToRestyle(aElement, aPseudoType); + + if (!elementToRestyle) { + // FIXME: Bug 1371107: When reframing happens, + // EffectCompositor::mElementsToRestyle still has unbinded old pseudo + // element. We should drop it. + return; + } + + Servo_NoteExplicitHints(elementToRestyle, aRestyleHint, nsChangeHint(0)); } void diff --git a/layout/base/ServoRestyleManager.h b/layout/base/ServoRestyleManager.h index 39f7d6d88998..21fcee0a1d14 100644 --- a/layout/base/ServoRestyleManager.h +++ b/layout/base/ServoRestyleManager.h @@ -107,6 +107,7 @@ public: * traversal of the same restyling process. */ static void PostRestyleEventForAnimations(dom::Element* aElement, + CSSPseudoElementType aPseudoType, nsRestyleHint aRestyleHint); protected: ~ServoRestyleManager() override diff --git a/layout/style/test/stylo-failures.md b/layout/style/test/stylo-failures.md index c22e99fd07c0..55c45733ee59 100644 --- a/layout/style/test/stylo-failures.md +++ b/layout/style/test/stylo-failures.md @@ -42,7 +42,6 @@ to mochitest command. * test_bug413958.html `monitorConsole` [3] * test_parser_diagnostics_unprintables.html [550] * Transition support: - * test_transitions.html: pseudo elements [4] * test_transitions_and_reframes.html `pseudo-element`: bug 1366422 [4] * Events: * test_animations_event_order.html [2]