Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / generic / ScrollGeneration.h
blob90eb243e9e87035e4a378bc498d3015585a50ae7
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/. */
5 #ifndef mozilla_ScrollGeneration_h_
6 #define mozilla_ScrollGeneration_h_
8 #include <cstdint>
9 #include <iosfwd>
11 namespace mozilla {
13 struct ScrollGenerationCounter;
15 class APZTag {};
16 class MainThreadTag {};
18 template <typename Tag>
19 struct ScrollGeneration;
21 template <typename Tag>
22 std::ostream& operator<<(std::ostream& aStream,
23 const ScrollGeneration<Tag>& aGen);
25 template <typename Tag>
26 struct ScrollGeneration {
27 friend struct ScrollGenerationCounter;
29 private:
30 // Private constructor; use ScrollGenerationCounter to get a new instance.
31 explicit ScrollGeneration(uint64_t aValue);
33 public:
34 // Dummy constructor, needed for IPDL purposes. Not intended for manual use.
35 ScrollGeneration();
37 uint64_t Raw() const { return mValue; }
39 bool operator<(const ScrollGeneration<Tag>& aOther) const;
40 bool operator==(const ScrollGeneration<Tag>& aOther) const;
41 bool operator!=(const ScrollGeneration<Tag>& aOther) const;
43 friend std::ostream& operator<< <>(std::ostream& aStream,
44 const ScrollGeneration<Tag>& aGen);
46 private:
47 uint64_t mValue;
50 using APZScrollGeneration = ScrollGeneration<APZTag>;
51 using MainThreadScrollGeneration = ScrollGeneration<MainThreadTag>;
53 struct ScrollGenerationCounter {
54 MainThreadScrollGeneration NewMainThreadGeneration() {
55 uint64_t value = ++mCounter;
56 return MainThreadScrollGeneration(value);
59 APZScrollGeneration NewAPZGeneration() {
60 uint64_t value = ++mCounter;
61 return APZScrollGeneration(value);
64 private:
65 uint64_t mCounter = 0;
68 } // namespace mozilla
70 #endif // mozilla_ScrollGeneration_h_