/src/mozilla-central/layout/painting/RetainedDisplayListBuilder.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef RETAINEDDISPLAYLISTBUILDER_H_ |
8 | | #define RETAINEDDISPLAYLISTBUILDER_H_ |
9 | | |
10 | | #include "nsDisplayList.h" |
11 | | #include "mozilla/Maybe.h" |
12 | | #include "mozilla/TypedEnumBits.h" |
13 | | |
14 | | namespace mozilla { |
15 | | class DisplayListChecker; |
16 | | } // namespace mozilla |
17 | | |
18 | | |
19 | | /** |
20 | | * RetainedDisplayListData contains frame invalidation information. It is stored |
21 | | * in root frames, and used by RetainedDisplayListBuilder. |
22 | | * Currently this is implemented as a map of frame pointers to flags. |
23 | | */ |
24 | | struct RetainedDisplayListData |
25 | | { |
26 | | NS_DECLARE_FRAME_PROPERTY_DELETABLE(DisplayListData, RetainedDisplayListData) |
27 | | |
28 | | enum class FrameFlags : uint8_t |
29 | | { |
30 | | None = 0, |
31 | | Modified = 1 << 0, |
32 | | HasProps = 1 << 1, |
33 | | HadWillChange = 1 << 2 |
34 | | }; |
35 | | |
36 | | /** |
37 | | * Removes all the frames from this RetainedDisplayListData. |
38 | | */ |
39 | 0 | void Clear() { mFrames.Clear(); } |
40 | | |
41 | | /** |
42 | | * Returns a mutable reference to flags set for the given |aFrame|. If the |
43 | | * frame does not exist in this RetainedDisplayListData, it is added with |
44 | | * default constructible flags FrameFlags::None. |
45 | | */ |
46 | 0 | FrameFlags& Flags(nsIFrame* aFrame) { return mFrames.GetOrInsert(aFrame); } |
47 | | |
48 | | /** |
49 | | * Returns flags set for the given |aFrame|, or FrameFlags::None if the frame |
50 | | * is not in this RetainedDisplayListData. |
51 | | */ |
52 | 0 | FrameFlags GetFlags(nsIFrame* aFrame) const { return mFrames.Get(aFrame); } |
53 | | |
54 | | /** |
55 | | * Returns an iterator to the underlying frame storage. |
56 | | */ |
57 | 0 | auto Iterator() { return mFrames.Iter(); } |
58 | | |
59 | | /** |
60 | | * Removes the given |aFrame| from this RetainedDisplayListData. |
61 | | */ |
62 | 0 | bool Remove(nsIFrame* aFrame) { return mFrames.Remove(aFrame); } |
63 | | |
64 | | private: |
65 | | nsDataHashtable<nsPtrHashKey<nsIFrame>, FrameFlags> mFrames; |
66 | | }; |
67 | | |
68 | | MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RetainedDisplayListData::FrameFlags) |
69 | | |
70 | | /** |
71 | | * Returns RetainedDisplayListData property for the given |aRootFrame|, or |
72 | | * nullptr if the property is not set. |
73 | | */ |
74 | | RetainedDisplayListData* |
75 | | GetRetainedDisplayListData(nsIFrame* aRootFrame); |
76 | | |
77 | | /** |
78 | | * Returns RetainedDisplayListData property for the given |aRootFrame|. Creates |
79 | | * and sets a new RetainedDisplayListData property if it is not already set. |
80 | | */ |
81 | | RetainedDisplayListData* |
82 | | GetOrSetRetainedDisplayListData(nsIFrame* aRootFrame); |
83 | | |
84 | | struct RetainedDisplayListBuilder |
85 | | { |
86 | | RetainedDisplayListBuilder(nsIFrame* aReferenceFrame, |
87 | | nsDisplayListBuilderMode aMode, |
88 | | bool aBuildCaret) |
89 | | : mBuilder(aReferenceFrame, aMode, aBuildCaret, true) |
90 | 0 | { |
91 | 0 | } |
92 | 0 | ~RetainedDisplayListBuilder() { mList.DeleteAll(&mBuilder); } |
93 | | |
94 | 0 | nsDisplayListBuilder* Builder() { return &mBuilder; } |
95 | | |
96 | 0 | nsDisplayList* List() { return &mList; } |
97 | | |
98 | | enum class PartialUpdateResult |
99 | | { |
100 | | Failed, |
101 | | NoChange, |
102 | | Updated |
103 | | }; |
104 | | |
105 | | PartialUpdateResult AttemptPartialUpdate( |
106 | | nscolor aBackstop, |
107 | | mozilla::DisplayListChecker* aChecker); |
108 | | |
109 | | /** |
110 | | * Iterates through the display list builder reference frame document and |
111 | | * subdocuments, and clears the modified frame lists from the root frames. |
112 | | * Also clears the frame properties set by RetainedDisplayListBuilder for all |
113 | | * the frames in the modified frame lists. |
114 | | */ |
115 | | void ClearFramesWithProps(); |
116 | | |
117 | | NS_DECLARE_FRAME_PROPERTY_DELETABLE(Cached, RetainedDisplayListBuilder) |
118 | | |
119 | | private: |
120 | | bool PreProcessDisplayList(RetainedDisplayList* aList, |
121 | | AnimatedGeometryRoot* aAGR, |
122 | | uint32_t aCallerKey = 0, |
123 | | uint32_t aNestingDepth = 0); |
124 | | bool MergeDisplayLists( |
125 | | nsDisplayList* aNewList, |
126 | | RetainedDisplayList* aOldList, |
127 | | RetainedDisplayList* aOutList, |
128 | | mozilla::Maybe<const mozilla::ActiveScrolledRoot*>& aOutContainerASR, |
129 | | uint32_t aOuterKey = 0); |
130 | | |
131 | | bool ComputeRebuildRegion(nsTArray<nsIFrame*>& aModifiedFrames, |
132 | | nsRect* aOutDirty, |
133 | | AnimatedGeometryRoot** aOutModifiedAGR, |
134 | | nsTArray<nsIFrame*>& aOutFramesWithProps); |
135 | | bool ProcessFrame(nsIFrame* aFrame, |
136 | | nsDisplayListBuilder& aBuilder, |
137 | | nsIFrame* aStopAtFrame, |
138 | | nsTArray<nsIFrame*>& aOutFramesWithProps, |
139 | | const bool aStopAtStackingContext, |
140 | | nsRect* aOutDirty, |
141 | | AnimatedGeometryRoot** aOutModifiedAGR); |
142 | | |
143 | | void IncrementSubDocPresShellPaintCount(nsDisplayItem* aItem); |
144 | | |
145 | | friend class MergeState; |
146 | | |
147 | | nsDisplayListBuilder mBuilder; |
148 | | RetainedDisplayList mList; |
149 | | WeakFrame mPreviousCaret; |
150 | | }; |
151 | | |
152 | | #endif // RETAINEDDISPLAYLISTBUILDER_H_ |