/src/mozilla-central/layout/painting/DisplayItemClipChain.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 DISPLAYITEMCLIPCHAIN_H_ |
8 | | #define DISPLAYITEMCLIPCHAIN_H_ |
9 | | |
10 | | #include "mozilla/Assertions.h" |
11 | | #include "DisplayItemClip.h" |
12 | | #include "nsString.h" |
13 | | |
14 | | class nsIScrollableFrame; |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | struct ActiveScrolledRoot; |
19 | | |
20 | | /** |
21 | | * A DisplayItemClipChain is a linked list of DisplayItemClips where each clip |
22 | | * is associated with an active scrolled root that describes what the clip |
23 | | * moves with. |
24 | | * We use a chain instead of just one intersected clip due to async scrolling: |
25 | | * A clip that moves along with a display item can be fused to the item's |
26 | | * contents when drawing the layer contents, but all other clips in the chain |
27 | | * need to be kept separate so that they can be applied at composition time, |
28 | | * after any async scroll offsets have been applied. |
29 | | * The clip chain is created during display list construction by the builder's |
30 | | * DisplayListClipState. |
31 | | * The clip chain order is determined by the active scrolled root order. |
32 | | * For every DisplayItemClipChain object |clipChain|, the following holds: |
33 | | * !clipChain->mParent || |
34 | | * ActiveScrolledRoot::IsAncestor(clipChain->mParent->mASR, clipChain->mASR). |
35 | | * The clip chain can skip over active scrolled roots. That just means that |
36 | | * there is no clip that moves with the skipped ASR in this chain. |
37 | | */ |
38 | | struct DisplayItemClipChain |
39 | | { |
40 | | |
41 | | /** |
42 | | * Get the display item clip in this chain that moves with aASR, or nullptr |
43 | | * if no such clip exists. aClipChain can be null. |
44 | | */ |
45 | | static const DisplayItemClip* ClipForASR( |
46 | | const DisplayItemClipChain* aClipChain, |
47 | | const ActiveScrolledRoot* aASR); |
48 | | |
49 | | static bool Equal(const DisplayItemClipChain* aClip1, |
50 | | const DisplayItemClipChain* aClip2); |
51 | | /** |
52 | | * Hash function that returns the same value for any two clips A and B |
53 | | * where Equal(A, B) is true. |
54 | | */ |
55 | | static uint32_t Hash(const DisplayItemClipChain* aClip); |
56 | | |
57 | | static nsCString ToString(const DisplayItemClipChain* aClipChain); |
58 | | |
59 | | bool HasRoundedCorners() const; |
60 | | |
61 | 0 | void AddRef() { mRefCount++; } |
62 | | void Release() |
63 | 0 | { |
64 | 0 | MOZ_ASSERT(mRefCount > 0); |
65 | 0 | mRefCount--; |
66 | 0 | } |
67 | | |
68 | | DisplayItemClipChain(const DisplayItemClip& aClip, |
69 | | const ActiveScrolledRoot* aASR, |
70 | | const DisplayItemClipChain* aParent, |
71 | | DisplayItemClipChain* aNextClipChainToDestroy) |
72 | | : mClip(aClip) |
73 | | , mASR(aASR) |
74 | | , mParent(aParent) |
75 | | , mNextClipChainToDestroy(aNextClipChainToDestroy) |
76 | | #ifdef DEBUG |
77 | | , mOnStack(true) |
78 | | #endif |
79 | 0 | { |
80 | 0 | } |
81 | | |
82 | | DisplayItemClipChain() |
83 | | : mASR(nullptr) |
84 | | , mNextClipChainToDestroy(nullptr) |
85 | | #ifdef DEBUG |
86 | | , mOnStack(true) |
87 | | #endif |
88 | 0 | { |
89 | 0 | } |
90 | | |
91 | | DisplayItemClip mClip; |
92 | | const ActiveScrolledRoot* mASR; |
93 | | RefPtr<const DisplayItemClipChain> mParent; |
94 | | uint32_t mRefCount = 0; |
95 | | DisplayItemClipChain* mNextClipChainToDestroy; |
96 | | #ifdef DEBUG |
97 | | bool mOnStack; |
98 | | #endif |
99 | | }; |
100 | | |
101 | | struct DisplayItemClipChainHasher |
102 | | { |
103 | | typedef const DisplayItemClipChain* Key; |
104 | | |
105 | | std::size_t operator()(const Key& aKey) const |
106 | 0 | { |
107 | 0 | return DisplayItemClipChain::Hash(aKey); |
108 | 0 | } |
109 | | }; |
110 | | |
111 | | struct DisplayItemClipChainEqualer |
112 | | { |
113 | | typedef const DisplayItemClipChain* Key; |
114 | | |
115 | | bool operator()(const Key& lhs, const Key& rhs) const |
116 | 0 | { |
117 | 0 | return DisplayItemClipChain::Equal(lhs, rhs); |
118 | 0 | } |
119 | | }; |
120 | | |
121 | | } // namespace mozilla |
122 | | |
123 | | #endif /* DISPLAYITEMCLIPCHAIN_H_ */ |