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 ServoComputedCustomProperties
{
26 uintptr_t mNonInherited
;
29 struct ServoRuleNode
{
35 } // namespace mozilla
37 #define STYLE_STRUCT(name_) struct nsStyle##name_;
38 #include "nsStyleStructList.h"
41 class ServoComputedData
;
43 struct ServoComputedDataForgotten
{
44 // Make sure you manually mem::forget the backing ServoComputedData
46 explicit ServoComputedDataForgotten(const ServoComputedData
* aValue
)
48 const ServoComputedData
* mPtr
;
52 * We want C++ to be able to read the style struct fields of ComputedValues
53 * so we define this type on the C++ side and use the bindgenned version
56 class ServoComputedData
{
57 friend class mozilla::ComputedStyle
;
60 // Constructs via memcpy. Will not move out of aValue.
61 explicit ServoComputedData(const ServoComputedDataForgotten aValue
);
63 #define STYLE_STRUCT(name_) \
64 const nsStyle##name_* name_; \
65 const nsStyle##name_* Style##name_() const MOZ_NONNULL_RETURN { \
68 #include "nsStyleStructList.h"
71 void AddSizeOfExcludingThis(nsWindowSizes
& aSizes
) const;
73 mozilla::ServoWritingMode
WritingMode() const { return writing_mode
; }
76 mozilla::ServoComputedCustomProperties custom_properties
;
77 mozilla::ServoWritingMode writing_mode
;
78 /// The effective zoom (as in, the CSS zoom property) of this style.
80 /// zoom is a non-inherited property, yet changes to it propagate through in
81 /// an inherited fashion, and all length resolution code need to access it.
82 /// This could, in theory, be stored in any other inherited struct, but it's
83 /// weird to have an inherited struct field depend on a non inherited
86 /// So the style object itself is probably a reasonable place to store it.
87 mozilla::StyleZoom effective_zoom
;
88 mozilla::StyleComputedValueFlags 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 const mozilla::ComputedStyle
* visited_style
;
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.
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;
111 #endif // mozilla_ServoComputedData_h