Bug 1568157 - Part 5: Move the NodePicker initialization into a getter. r=yulia
[gecko.git] / layout / painting / ActiveLayerTracker.h
blob01eef9244922aca32131b013a036c4dc5bb5bc41
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"
12 class nsIFrame;
13 class nsIContent;
14 class nsCSSPropertyIDSet;
15 class nsDisplayListBuilder;
16 class nsDOMCSSDeclaration;
18 namespace mozilla {
20 /**
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
24 * heuristics.
26 class ActiveLayerTracker {
27 public:
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.
40 /**
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);
47 /**
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);
53 /**
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
57 * value has changed.
59 static void NotifyAnimated(nsIFrame* aFrame, nsCSSPropertyID aProperty,
60 const nsAString& aNewValue,
61 nsDOMCSSDeclaration* aDOMCSSDecl);
62 /**
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);
69 /**
70 * Notify that a property in the inline style rule of aFrame's element
71 * has been modified.
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
75 * value has changed.
77 static void NotifyInlineStyleRuleModified(nsIFrame* aFrame,
78 nsCSSPropertyID aProperty,
79 const nsAString& aNewValue,
80 nsDOMCSSDeclaration* aDOMCSSDecl);
81 /**
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
85 * layer.
87 static void NotifyNeedsRepaint(nsIFrame* aFrame);
88 /**
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);
94 /**
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);
99 /**
100 * Return true if aFrame's background-position-x or background-position-y
101 * property is animated.
103 static bool IsBackgroundPositionAnimated(nsDisplayListBuilder* aBuilder,
104 nsIFrame* aFrame);
106 * Return true if aFrame's transform-like property,
107 * i.e. transform/translate/rotate/scale, is animated.
109 static bool IsTransformAnimated(nsDisplayListBuilder* aBuilder,
110 nsIFrame* aFrame);
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
143 * a short period.
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_ */