1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef ACTIVELAYERTRACKER_H_
8 #define ACTIVELAYERTRACKER_H_
10 #include "nsCSSPropertyID.h"
14 class nsCSSPropertyIDSet
;
15 class nsDisplayListBuilder
;
16 class nsDOMCSSDeclaration
;
21 * This class receives various notifications about style changes and content
22 * changes that affect layerization decisions, and implements the heuristics
23 * that drive those decisions. It manages per-frame state to support those
26 class ActiveLayerTracker
{
28 static void Shutdown();
31 * We track style changes to selected styles:
32 * eCSSProperty_transform, eCSSProperty_translate,
33 * eCSSProperty_rotate, eCSSProperty_scale
34 * eCSSProperty_opacity
35 * eCSSProperty_left, eCSSProperty_top,
36 * eCSSProperty_right, eCSSProperty_bottom
37 * and use that information to guess whether style changes are animated.
41 * Notify aFrame's style property as having changed due to a restyle,
42 * and therefore possibly wanting an active layer to render that style.
43 * Any such marking will time out after a short period.
44 * @param aProperty the property that has changed
46 static void NotifyRestyle(nsIFrame
* aFrame
, nsCSSPropertyID aProperty
);
48 * Notify aFrame's left/top/right/bottom properties as having (maybe)
49 * changed due to a restyle, and therefore possibly wanting an active layer
50 * to render that style. Any such marking will time out after a short period.
52 static void NotifyOffsetRestyle(nsIFrame
* aFrame
);
54 * Mark aFrame as being known to have an animation of aProperty.
55 * Any such marking will time out after a short period.
56 * aNewValue and aDOMCSSDecl are used to determine whether the property's
59 static void NotifyAnimated(nsIFrame
* aFrame
, nsCSSPropertyID aProperty
,
60 const nsAString
& aNewValue
,
61 nsDOMCSSDeclaration
* aDOMCSSDecl
);
63 * Notify aFrame as being known to have an animation of aProperty through an
64 * inline style modification during aScrollFrame's scroll event handler.
66 static void NotifyAnimatedFromScrollHandler(nsIFrame
* aFrame
,
67 nsCSSPropertyID aProperty
,
68 nsIFrame
* aScrollFrame
);
70 * Notify that a property in the inline style rule of aFrame's element
72 * This notification is incomplete --- not all modifications to inline
73 * style will trigger this.
74 * aNewValue and aDOMCSSDecl are used to determine whether the property's
77 static void NotifyInlineStyleRuleModified(nsIFrame
* aFrame
,
78 nsCSSPropertyID aProperty
,
79 const nsAString
& aNewValue
,
80 nsDOMCSSDeclaration
* aDOMCSSDecl
);
82 * Notify that a frame needs to be repainted. This is important for layering
83 * decisions where, say, aFrame's transform is updated from JS, but we need
84 * to repaint aFrame anyway, so we get no benefit from giving it its own
87 static void NotifyNeedsRepaint(nsIFrame
* aFrame
);
89 * Return true if aFrame's property style in |aPropertySet| should be
90 * considered as being animated for constructing active layers.
92 static bool IsStyleAnimated(nsDisplayListBuilder
* aBuilder
, nsIFrame
* aFrame
,
93 const nsCSSPropertyIDSet
& aPropertySet
);
95 * Return true if any of aFrame's offset property styles should be considered
96 * as being animated for constructing active layers.
98 static bool IsOffsetStyleAnimated(nsIFrame
* aFrame
);
100 * Return true if aFrame's background-position-x or background-position-y
101 * property is animated.
103 static bool IsBackgroundPositionAnimated(nsDisplayListBuilder
* aBuilder
,
106 * Return true if aFrame's transform-like property,
107 * i.e. transform/translate/rotate/scale, is animated.
109 static bool IsTransformAnimated(nsDisplayListBuilder
* aBuilder
,
112 * Return true if aFrame's transform style should be considered as being
113 * animated for pre-rendering.
115 static bool IsTransformMaybeAnimated(nsIFrame
* aFrame
);
117 * Return true if aFrame either has an animated scale now, or is likely to
118 * have one in the future because it has a CSS animation or transition
119 * (which may not be playing right now) that affects its scale.
121 static bool IsScaleSubjectToAnimation(nsIFrame
* aFrame
);
124 * Transfer the LayerActivity property to the frame's content node when the
125 * frame is about to be destroyed so that layer activity can be tracked
126 * throughout reframes of an element. Only call this when aFrame is the
127 * primary frame of aContent.
129 static void TransferActivityToContent(nsIFrame
* aFrame
, nsIContent
* aContent
);
131 * Transfer the LayerActivity property back to the content node's primary
132 * frame after the frame has been created.
134 static void TransferActivityToFrame(nsIContent
* aContent
, nsIFrame
* aFrame
);
137 * We track modifications to the content of certain frames (i.e. canvas
138 * frames) and use that to make layering decisions.
142 * Mark aFrame's content as being active. This marking will time out after
145 static void NotifyContentChange(nsIFrame
* aFrame
);
147 * Return true if this frame's content is still marked as active.
149 static bool IsContentActive(nsIFrame
* aFrame
);
152 * Called before and after a scroll event handler is executed, with the
153 * scrollframe or nullptr, respectively. This acts as a hint to treat
154 * inline style changes during the handler differently.
156 static void SetCurrentScrollHandlerFrame(nsIFrame
* aFrame
);
159 } // namespace mozilla
161 #endif /* ACTIVELAYERTRACKER_H_ */