/work/obj-fuzz/dist/include/mozilla/ServoComputedData.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 mozilla_ServoComputedData_h |
8 | | #define mozilla_ServoComputedData_h |
9 | | |
10 | | #include "mozilla/ServoTypes.h" |
11 | | |
12 | | /* |
13 | | * ServoComputedData and its related types. |
14 | | */ |
15 | | |
16 | | #define STYLE_STRUCT(name_) struct nsStyle##name_; |
17 | | #include "nsStyleStructList.h" |
18 | | #undef STYLE_STRUCT |
19 | | |
20 | | namespace mozilla { |
21 | | |
22 | | struct ServoWritingMode { |
23 | | uint8_t mBits; |
24 | | }; |
25 | | |
26 | | struct ServoCustomPropertiesMap { |
27 | | uintptr_t mPtr; |
28 | | }; |
29 | | |
30 | | struct ServoRuleNode { |
31 | | uintptr_t mPtr; |
32 | | }; |
33 | | |
34 | | class ComputedStyle; |
35 | | |
36 | | struct ServoVisitedStyle { |
37 | | // This is actually a strong reference |
38 | | // but ServoComputedData's destructor is |
39 | | // managed by the Rust code so we just use a |
40 | | // regular pointer |
41 | | ComputedStyle* mPtr; |
42 | | }; |
43 | | |
44 | | struct ServoComputedValueFlags { |
45 | | uint16_t mFlags; |
46 | | }; |
47 | | |
48 | | #define STYLE_STRUCT(name_) struct Gecko##name_; |
49 | | #include "nsStyleStructList.h" |
50 | | #undef STYLE_STRUCT |
51 | | |
52 | | } // namespace mozilla |
53 | | |
54 | | class ServoComputedData; |
55 | | |
56 | | struct ServoComputedDataForgotten |
57 | | { |
58 | | // Make sure you manually mem::forget the backing ServoComputedData |
59 | | // after calling this |
60 | 0 | explicit ServoComputedDataForgotten(const ServoComputedData* aValue) : mPtr(aValue) {} |
61 | | const ServoComputedData* mPtr; |
62 | | }; |
63 | | |
64 | | /** |
65 | | * We want C++ to be able to read the style struct fields of ComputedValues |
66 | | * so we define this type on the C++ side and use the bindgenned version |
67 | | * on the Rust side. |
68 | | */ |
69 | | class ServoComputedData |
70 | | { |
71 | | friend class mozilla::ComputedStyle; |
72 | | |
73 | | public: |
74 | | // Constructs via memcpy. Will not move out of aValue. |
75 | | explicit ServoComputedData(const ServoComputedDataForgotten aValue); |
76 | | |
77 | | #define STYLE_STRUCT(name_) \ |
78 | | mozilla::ServoRawOffsetArc<mozilla::Gecko##name_> name_; \ |
79 | | inline const nsStyle##name_* GetStyle##name_() const; |
80 | | #include "nsStyleStructList.h" |
81 | | #undef STYLE_STRUCT |
82 | | |
83 | | void AddSizeOfExcludingThis(nsWindowSizes& aSizes) const; |
84 | | |
85 | | private: |
86 | | mozilla::ServoCustomPropertiesMap custom_properties; |
87 | | mozilla::ServoWritingMode writing_mode; |
88 | | mozilla::ServoComputedValueFlags flags; |
89 | | /// The rule node representing the ordered list of rules matched for this |
90 | | /// node. Can be None for default values and text nodes. This is |
91 | | /// essentially an optimization to avoid referencing the root rule node. |
92 | | mozilla::ServoRuleNode rules; |
93 | | /// The element's computed values if visited, only computed if there's a |
94 | | /// relevant link for this element. A element's "relevant link" is the |
95 | | /// element being matched if it is a link or the nearest ancestor link. |
96 | | mozilla::ServoVisitedStyle visited_style; |
97 | | |
98 | | // C++ just sees this struct as a bucket of bits, and will |
99 | | // do the wrong thing if we let it use the default copy ctor/assignment |
100 | | // operator. Remove them so that there is no footgun. |
101 | | // |
102 | | // We remove the move ctor/assignment operator as well, because |
103 | | // moves in C++ don't prevent destructors from being called, |
104 | | // which will lead to double frees. |
105 | | ServoComputedData& operator=(const ServoComputedData&) = delete; |
106 | | ServoComputedData(const ServoComputedData&) = delete; |
107 | | ServoComputedData&& operator=(const ServoComputedData&&) = delete; |
108 | | ServoComputedData(const ServoComputedData&&) = delete; |
109 | | }; |
110 | | |
111 | | #endif // mozilla_ServoComputedData_h |