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/. */
7 #ifndef mozilla_ServoComputedData_h
8 #define mozilla_ServoComputedData_h
12 #include "mozilla/ServoStyleConsts.h"
15 * ServoComputedData and its related types.
20 struct ServoWritingMode
{
24 struct ServoCustomPropertiesMap
{
28 struct ServoRuleNode
{
34 } // namespace mozilla
36 #define STYLE_STRUCT(name_) struct nsStyle##name_;
37 #include "nsStyleStructList.h"
40 class ServoComputedData
;
42 struct ServoComputedDataForgotten
{
43 // Make sure you manually mem::forget the backing ServoComputedData
45 explicit ServoComputedDataForgotten(const ServoComputedData
* aValue
)
47 const ServoComputedData
* mPtr
;
51 * We want C++ to be able to read the style struct fields of ComputedValues
52 * so we define this type on the C++ side and use the bindgenned version
55 class ServoComputedData
{
56 friend class mozilla::ComputedStyle
;
59 // Constructs via memcpy. Will not move out of aValue.
60 explicit ServoComputedData(const ServoComputedDataForgotten aValue
);
62 #define STYLE_STRUCT(name_) \
63 const nsStyle##name_* name_; \
64 const nsStyle##name_* Style##name_() const MOZ_NONNULL_RETURN { \
67 #include "nsStyleStructList.h"
70 void AddSizeOfExcludingThis(nsWindowSizes
& aSizes
) const;
72 mozilla::ServoWritingMode
WritingMode() const { return writing_mode
; }
75 mozilla::ServoCustomPropertiesMap custom_properties
;
76 mozilla::ServoWritingMode writing_mode
;
77 mozilla::StyleComputedValueFlags flags
;
78 /// The rule node representing the ordered list of rules matched for this
79 /// node. Can be None for default values and text nodes. This is
80 /// essentially an optimization to avoid referencing the root rule node.
81 mozilla::ServoRuleNode rules
;
82 /// The element's computed values if visited, only computed if there's a
83 /// relevant link for this element. A element's "relevant link" is the
84 /// element being matched if it is a link or the nearest ancestor link.
85 const mozilla::ComputedStyle
* visited_style
;
87 // C++ just sees this struct as a bucket of bits, and will
88 // do the wrong thing if we let it use the default copy ctor/assignment
89 // operator. Remove them so that there is no footgun.
91 // We remove the move ctor/assignment operator as well, because
92 // moves in C++ don't prevent destructors from being called,
93 // which will lead to double frees.
94 ServoComputedData
& operator=(const ServoComputedData
&) = delete;
95 ServoComputedData(const ServoComputedData
&) = delete;
96 ServoComputedData
&& operator=(const ServoComputedData
&&) = delete;
97 ServoComputedData(const ServoComputedData
&&) = delete;
100 #endif // mozilla_ServoComputedData_h