|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef ACTIVELAYERTRACKER_H_ |
|
6 #define ACTIVELAYERTRACKER_H_ |
|
7 |
|
8 #include "nsCSSProperty.h" |
|
9 |
|
10 class nsIFrame; |
|
11 |
|
12 namespace mozilla { |
|
13 |
|
14 /** |
|
15 * This class receives various notifications about style changes and content |
|
16 * changes that affect layerization decisions, and implements the heuristics |
|
17 * that drive those decisions. It manages per-frame state to support those |
|
18 * heuristics. |
|
19 */ |
|
20 class ActiveLayerTracker { |
|
21 public: |
|
22 static void Shutdown(); |
|
23 |
|
24 /* |
|
25 * We track style changes to selected styles: |
|
26 * eCSSProperty_transform |
|
27 * eCSSProperty_opacity |
|
28 * eCSSProperty_left, eCSSProperty_top, eCSSProperty_right, eCSSProperty_bottom |
|
29 * and use that information to guess whether style changes are animated. |
|
30 */ |
|
31 |
|
32 /** |
|
33 * Notify aFrame's style property as having changed due to a restyle, |
|
34 * and therefore possibly wanting an active layer to render that style. |
|
35 * Any such marking will time out after a short period. |
|
36 * @param aProperty the property that has changed |
|
37 */ |
|
38 static void NotifyRestyle(nsIFrame* aFrame, nsCSSProperty aProperty); |
|
39 /** |
|
40 * Notify aFrame's left/top/right/bottom properties as having (maybe) |
|
41 * changed due to a restyle, and therefore possibly wanting an active layer |
|
42 * to render that style. Any such marking will time out after a short period. |
|
43 */ |
|
44 static void NotifyOffsetRestyle(nsIFrame* aFrame); |
|
45 /** |
|
46 * Mark aFrame as being known to have an animation of aProperty. |
|
47 * Any such marking will time out after a short period. |
|
48 */ |
|
49 static void NotifyAnimated(nsIFrame* aFrame, nsCSSProperty aProperty); |
|
50 /** |
|
51 * Notify that a property in the inline style rule of aFrame's element |
|
52 * has been modified. |
|
53 * This notification is incomplete --- not all modifications to inline |
|
54 * style will trigger this. |
|
55 */ |
|
56 static void NotifyInlineStyleRuleModified(nsIFrame* aFrame, nsCSSProperty aProperty); |
|
57 /** |
|
58 * Return true if aFrame's aProperty style should be considered as being animated |
|
59 * for constructing active layers. |
|
60 */ |
|
61 static bool IsStyleAnimated(nsIFrame* aFrame, nsCSSProperty aProperty); |
|
62 /** |
|
63 * Return true if any of aFrame's offset property styles should be considered |
|
64 * as being animated for constructing active layers. |
|
65 */ |
|
66 static bool IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame); |
|
67 |
|
68 /* |
|
69 * We track modifications to the content of certain frames (i.e. canvas frames) |
|
70 * and use that to make layering decisions. |
|
71 */ |
|
72 |
|
73 /** |
|
74 * Mark aFrame's content as being active. This marking will time out after |
|
75 * a short period. |
|
76 */ |
|
77 static void NotifyContentChange(nsIFrame* aFrame); |
|
78 /** |
|
79 * Return true if this frame's content is still marked as active. |
|
80 */ |
|
81 static bool IsContentActive(nsIFrame* aFrame); |
|
82 }; |
|
83 |
|
84 } |
|
85 |
|
86 #endif /* ACTIVELAYERTRACKER_H_ */ |