mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
9d38cfb2a9
This simplifies a tiny bit our bindings in some places, and complicates it in others, but over all I think it's better. It requires a bit more manual code in the rust side to drop and cast the relevant pointers (which was done implicitly before), but it's a lot less magic than it used to be, and that's all autogenerated so consumers don't need to care about it. The set up is still not ideal. I don't like that we rely on destructors running in both sides of the FFI boundary, but that's for another day. This is the last usage of RawOffsetArc, so remove that. We now support proper Arc<> in structs (GridTemplateAreas uses it), so I don't think we'll need it any time soon. Differential Revision: https://phabricator.services.mozilla.com/D177905
101 lines
3.2 KiB
C++
101 lines
3.2 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_ServoComputedData_h
|
|
#define mozilla_ServoComputedData_h
|
|
|
|
class nsWindowSizes;
|
|
|
|
#include "mozilla/ServoStyleConsts.h"
|
|
|
|
/*
|
|
* ServoComputedData and its related types.
|
|
*/
|
|
|
|
namespace mozilla {
|
|
|
|
struct ServoWritingMode {
|
|
uint8_t mBits;
|
|
};
|
|
|
|
struct ServoCustomPropertiesMap {
|
|
uintptr_t mPtr;
|
|
};
|
|
|
|
struct ServoRuleNode {
|
|
uintptr_t mPtr;
|
|
};
|
|
|
|
class ComputedStyle;
|
|
|
|
} // namespace mozilla
|
|
|
|
#define STYLE_STRUCT(name_) struct nsStyle##name_;
|
|
#include "nsStyleStructList.h"
|
|
#undef STYLE_STRUCT
|
|
|
|
class ServoComputedData;
|
|
|
|
struct ServoComputedDataForgotten {
|
|
// Make sure you manually mem::forget the backing ServoComputedData
|
|
// after calling this
|
|
explicit ServoComputedDataForgotten(const ServoComputedData* aValue)
|
|
: mPtr(aValue) {}
|
|
const ServoComputedData* mPtr;
|
|
};
|
|
|
|
/**
|
|
* We want C++ to be able to read the style struct fields of ComputedValues
|
|
* so we define this type on the C++ side and use the bindgenned version
|
|
* on the Rust side.
|
|
*/
|
|
class ServoComputedData {
|
|
friend class mozilla::ComputedStyle;
|
|
|
|
public:
|
|
// Constructs via memcpy. Will not move out of aValue.
|
|
explicit ServoComputedData(const ServoComputedDataForgotten aValue);
|
|
|
|
#define STYLE_STRUCT(name_) \
|
|
const nsStyle##name_* name_; \
|
|
const nsStyle##name_* Style##name_() const MOZ_NONNULL_RETURN { \
|
|
return name_; \
|
|
}
|
|
#include "nsStyleStructList.h"
|
|
#undef STYLE_STRUCT
|
|
|
|
void AddSizeOfExcludingThis(nsWindowSizes& aSizes) const;
|
|
|
|
mozilla::ServoWritingMode WritingMode() const { return writing_mode; }
|
|
|
|
private:
|
|
mozilla::ServoCustomPropertiesMap custom_properties;
|
|
mozilla::ServoWritingMode writing_mode;
|
|
mozilla::StyleComputedValueFlags flags;
|
|
/// The rule node representing the ordered list of rules matched for this
|
|
/// node. Can be None for default values and text nodes. This is
|
|
/// essentially an optimization to avoid referencing the root rule node.
|
|
mozilla::ServoRuleNode rules;
|
|
/// The element's computed values if visited, only computed if there's a
|
|
/// relevant link for this element. A element's "relevant link" is the
|
|
/// element being matched if it is a link or the nearest ancestor link.
|
|
const mozilla::ComputedStyle* visited_style;
|
|
|
|
// C++ just sees this struct as a bucket of bits, and will
|
|
// do the wrong thing if we let it use the default copy ctor/assignment
|
|
// operator. Remove them so that there is no footgun.
|
|
//
|
|
// We remove the move ctor/assignment operator as well, because
|
|
// moves in C++ don't prevent destructors from being called,
|
|
// which will lead to double frees.
|
|
ServoComputedData& operator=(const ServoComputedData&) = delete;
|
|
ServoComputedData(const ServoComputedData&) = delete;
|
|
ServoComputedData&& operator=(const ServoComputedData&&) = delete;
|
|
ServoComputedData(const ServoComputedData&&) = delete;
|
|
};
|
|
|
|
#endif // mozilla_ServoComputedData_h
|