2016-10-24 12:16:46 +03:00
|
|
|
/* -*- 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_ServoBindingTypes_h
|
|
|
|
#define mozilla_ServoBindingTypes_h
|
|
|
|
|
|
|
|
#include "mozilla/RefPtr.h"
|
2016-12-01 04:34:54 +03:00
|
|
|
#include "mozilla/ServoTypes.h"
|
2016-10-24 12:16:46 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-06-07 06:25:14 +03:00
|
|
|
#include "mozilla/gfx/Types.h"
|
2017-05-19 10:58:47 +03:00
|
|
|
#include "nsCSSPropertyID.h"
|
2017-03-10 05:53:17 +03:00
|
|
|
#include "nsStyleAutoArray.h"
|
2016-12-01 04:34:54 +03:00
|
|
|
#include "nsTArray.h"
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
struct RawServoStyleSet;
|
2017-10-02 13:07:11 +03:00
|
|
|
struct RawServoSelectorList;
|
2017-05-01 12:45:41 +03:00
|
|
|
struct RawServoAnimationValueMap;
|
2017-09-15 23:11:37 +03:00
|
|
|
struct RustString;
|
2016-11-23 03:35:55 +03:00
|
|
|
|
|
|
|
#define SERVO_ARC_TYPE(name_, type_) struct type_;
|
|
|
|
#include "mozilla/ServoArcTypeList.h"
|
|
|
|
#undef SERVO_ARC_TYPE
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
2017-04-04 03:04:13 +03:00
|
|
|
class ServoElementSnapshot;
|
2017-07-17 21:42:00 +03:00
|
|
|
class ServoStyleContext;
|
2017-04-04 03:04:13 +03:00
|
|
|
struct StyleAnimation;
|
2017-03-30 10:54:48 +03:00
|
|
|
struct URLExtraData;
|
2016-10-24 12:16:46 +03:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
class StyleChildrenIterator;
|
|
|
|
} // namespace dom
|
2017-04-06 04:34:51 +03:00
|
|
|
struct AnimationPropertySegment;
|
|
|
|
struct ComputedTiming;
|
2017-01-29 06:58:39 +03:00
|
|
|
struct Keyframe;
|
2017-07-20 08:38:54 +03:00
|
|
|
struct PropertyValuePair;
|
2016-12-01 04:34:54 +03:00
|
|
|
struct PropertyStyleAnimationValuePair;
|
2017-08-12 13:19:22 +03:00
|
|
|
enum class OriginFlags : uint8_t;
|
2017-02-23 03:52:43 +03:00
|
|
|
using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
|
2016-10-24 12:16:46 +03:00
|
|
|
} // namespace mozilla
|
2017-06-07 06:25:14 +03:00
|
|
|
namespace nsStyleTransformMatrix {
|
|
|
|
enum class MatrixTransformOperator: uint8_t;
|
|
|
|
}
|
2016-10-24 12:16:46 +03:00
|
|
|
|
2017-05-19 10:58:47 +03:00
|
|
|
class nsCSSPropertyIDSet;
|
2016-11-01 02:30:43 +03:00
|
|
|
class nsCSSValue;
|
2017-03-27 09:53:27 +03:00
|
|
|
struct nsFontFaceRuleContainer;
|
2016-10-24 12:16:46 +03:00
|
|
|
class nsIDocument;
|
|
|
|
class nsINode;
|
2017-01-04 22:52:26 +03:00
|
|
|
class nsPresContext;
|
2017-10-23 23:36:59 +03:00
|
|
|
class nsSimpleContentList;
|
2017-03-21 09:27:46 +03:00
|
|
|
struct nsTimingFunction;
|
2017-06-05 09:00:27 +03:00
|
|
|
class nsXBLBinding;
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
using mozilla::dom::StyleChildrenIterator;
|
2016-11-02 09:11:24 +03:00
|
|
|
using mozilla::ServoElementSnapshot;
|
2016-10-24 12:16:46 +03:00
|
|
|
|
2017-08-02 21:24:35 +03:00
|
|
|
typedef void* RawServoAnimationValueTableBorrowed;
|
|
|
|
|
2016-10-24 12:16:46 +03:00
|
|
|
typedef nsINode RawGeckoNode;
|
|
|
|
typedef mozilla::dom::Element RawGeckoElement;
|
|
|
|
typedef nsIDocument RawGeckoDocument;
|
2017-01-04 22:52:26 +03:00
|
|
|
typedef nsPresContext RawGeckoPresContext;
|
2017-06-05 09:00:27 +03:00
|
|
|
typedef nsXBLBinding RawGeckoXBLBinding;
|
2017-04-04 03:04:13 +03:00
|
|
|
typedef mozilla::URLExtraData RawGeckoURLExtraData;
|
2017-06-09 00:19:37 +03:00
|
|
|
typedef nsTArray<RefPtr<RawServoAnimationValue>> RawGeckoServoAnimationValueList;
|
2017-01-29 06:58:39 +03:00
|
|
|
typedef nsTArray<mozilla::Keyframe> RawGeckoKeyframeList;
|
2017-07-20 08:38:54 +03:00
|
|
|
typedef nsTArray<mozilla::PropertyValuePair> RawGeckoPropertyValuePairList;
|
2017-02-23 03:52:43 +03:00
|
|
|
typedef nsTArray<mozilla::ComputedKeyframeValues> RawGeckoComputedKeyframeValuesList;
|
2017-03-10 05:53:17 +03:00
|
|
|
typedef nsStyleAutoArray<mozilla::StyleAnimation> RawGeckoStyleAnimationList;
|
2017-03-27 09:53:27 +03:00
|
|
|
typedef nsTArray<nsFontFaceRuleContainer> RawGeckoFontFaceRuleList;
|
2017-04-06 04:34:51 +03:00
|
|
|
typedef mozilla::AnimationPropertySegment RawGeckoAnimationPropertySegment;
|
|
|
|
typedef mozilla::ComputedTiming RawGeckoComputedTiming;
|
2017-04-06 20:19:00 +03:00
|
|
|
typedef nsTArray<const RawServoStyleRule*> RawGeckoServoStyleRuleList;
|
2017-05-19 10:58:47 +03:00
|
|
|
typedef nsTArray<nsCSSPropertyID> RawGeckoCSSPropertyIDList;
|
2017-06-07 06:25:14 +03:00
|
|
|
typedef mozilla::gfx::Float RawGeckoGfxMatrix4x4[16];
|
2017-06-28 09:56:13 +03:00
|
|
|
typedef mozilla::dom::StyleChildrenIterator RawGeckoStyleChildrenIterator;
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
// We have these helper types so that we can directly generate
|
|
|
|
// things like &T or Borrowed<T> on the Rust side in the function, providing
|
|
|
|
// additional safety benefits.
|
|
|
|
//
|
|
|
|
// FFI has a problem with templated types, so we just use raw pointers here.
|
|
|
|
//
|
|
|
|
// The "Borrowed" types generate &T or Borrowed<T> in the nullable case.
|
|
|
|
//
|
|
|
|
// The "Owned" types generate Owned<T> or OwnedOrNull<T>. Some of these
|
|
|
|
// are Servo-managed and can be converted to Box<ServoType> on the
|
|
|
|
// Servo side.
|
|
|
|
//
|
|
|
|
// The "Arc" types are Servo-managed Arc<ServoType>s, which are passed
|
|
|
|
// over FFI as Strong<T> (which is nullable).
|
|
|
|
// Note that T != ServoType, rather T is ArcInner<ServoType>
|
|
|
|
#define DECL_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##Borrowed;
|
|
|
|
#define DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##BorrowedOrNull;
|
|
|
|
#define DECL_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMut;
|
|
|
|
#define DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMutOrNull;
|
|
|
|
|
2016-11-23 03:35:55 +03:00
|
|
|
#define SERVO_ARC_TYPE(name_, type_) \
|
2016-10-24 12:16:46 +03:00
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(type_) \
|
2017-01-20 02:56:53 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(type_) \
|
2016-10-24 12:16:46 +03:00
|
|
|
struct MOZ_MUST_USE_TYPE type_##Strong \
|
|
|
|
{ \
|
|
|
|
type_* mPtr; \
|
|
|
|
already_AddRefed<type_> Consume(); \
|
|
|
|
};
|
2016-11-23 03:35:55 +03:00
|
|
|
#include "mozilla/ServoArcTypeList.h"
|
|
|
|
#undef SERVO_ARC_TYPE
|
2016-10-24 12:16:46 +03:00
|
|
|
|
2017-07-17 21:42:00 +03:00
|
|
|
typedef mozilla::ServoStyleContext const* ServoStyleContextBorrowed;
|
|
|
|
typedef mozilla::ServoStyleContext const* ServoStyleContextBorrowedOrNull;
|
2017-07-21 07:44:02 +03:00
|
|
|
typedef ServoComputedData const* ServoComputedDataBorrowed;
|
2017-07-17 21:42:08 +03:00
|
|
|
|
2017-07-17 21:42:00 +03:00
|
|
|
struct MOZ_MUST_USE_TYPE ServoStyleContextStrong
|
|
|
|
{
|
|
|
|
mozilla::ServoStyleContext* mPtr;
|
|
|
|
already_AddRefed<mozilla::ServoStyleContext> Consume();
|
|
|
|
};
|
|
|
|
|
2016-10-24 12:16:46 +03:00
|
|
|
#define DECL_OWNED_REF_TYPE_FOR(type_) \
|
|
|
|
typedef type_* type_##Owned; \
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(type_) \
|
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(type_)
|
|
|
|
|
|
|
|
#define DECL_NULLABLE_OWNED_REF_TYPE_FOR(type_) \
|
|
|
|
typedef type_* type_##OwnedOrNull; \
|
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
|
|
|
|
DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_)
|
|
|
|
|
|
|
|
// This is a reference to a reference of RawServoDeclarationBlock, which
|
|
|
|
// corresponds to Option<&Arc<RawServoDeclarationBlock>> in Servo side.
|
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoDeclarationBlockStrong)
|
|
|
|
|
|
|
|
DECL_OWNED_REF_TYPE_FOR(RawServoStyleSet)
|
2017-06-05 09:00:27 +03:00
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawServoStyleSet)
|
2016-10-24 12:16:46 +03:00
|
|
|
DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
|
|
|
|
DECL_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
|
2016-11-02 09:11:24 +03:00
|
|
|
DECL_OWNED_REF_TYPE_FOR(ServoElementSnapshot)
|
2017-05-01 12:45:41 +03:00
|
|
|
DECL_OWNED_REF_TYPE_FOR(RawServoAnimationValueMap)
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
// We don't use BorrowedMut because the nodes may alias
|
|
|
|
// Servo itself doesn't directly read or mutate these;
|
|
|
|
// it only asks Gecko to do so. In case we wish to in
|
|
|
|
// the future, we should ensure that things being mutated
|
|
|
|
// are protected from noalias violations by a cell type
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoNode)
|
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoNode)
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoElement)
|
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoElement)
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoDocument)
|
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoDocument)
|
2017-06-05 09:00:27 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoXBLBinding)
|
|
|
|
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(RawGeckoXBLBinding)
|
2016-10-24 12:16:46 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(StyleChildrenIterator)
|
2016-11-02 09:11:24 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(ServoElementSnapshot)
|
2016-11-01 02:30:43 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(nsCSSValue)
|
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSValue)
|
2017-01-15 01:34:49 +03:00
|
|
|
DECL_OWNED_REF_TYPE_FOR(RawGeckoPresContext)
|
2017-01-04 22:52:26 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoPresContext)
|
2017-06-09 00:19:37 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoServoAnimationValueList)
|
2017-06-09 00:19:38 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoServoAnimationValueList)
|
2017-01-29 06:58:39 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoKeyframeList)
|
2017-02-23 03:52:43 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoKeyframeList)
|
2017-07-20 08:38:54 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoPropertyValuePairList)
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoPropertyValuePairList)
|
2017-02-23 03:52:43 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoComputedKeyframeValuesList)
|
2017-10-10 11:00:28 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoStyleAnimationList)
|
2017-03-10 05:53:17 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoStyleAnimationList)
|
2017-03-21 09:27:46 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(nsTimingFunction)
|
2017-03-21 09:29:43 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(nsTimingFunction)
|
2017-03-27 09:53:27 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoFontFaceRuleList)
|
2017-04-06 04:34:51 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoAnimationPropertySegment)
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoComputedTiming)
|
2017-04-06 20:19:00 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoServoStyleRuleList)
|
2017-05-19 10:58:47 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSPropertyIDSet)
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawGeckoCSSPropertyIDList)
|
2017-06-05 09:00:27 +03:00
|
|
|
DECL_BORROWED_REF_TYPE_FOR(nsXBLBinding)
|
2017-06-28 09:56:13 +03:00
|
|
|
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoStyleChildrenIterator)
|
2017-10-02 13:07:11 +03:00
|
|
|
DECL_OWNED_REF_TYPE_FOR(RawServoSelectorList)
|
|
|
|
DECL_BORROWED_REF_TYPE_FOR(RawServoSelectorList)
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
#undef DECL_ARC_REF_TYPE_FOR
|
|
|
|
#undef DECL_OWNED_REF_TYPE_FOR
|
|
|
|
#undef DECL_NULLABLE_OWNED_REF_TYPE_FOR
|
|
|
|
#undef DECL_BORROWED_REF_TYPE_FOR
|
|
|
|
#undef DECL_NULLABLE_BORROWED_REF_TYPE_FOR
|
|
|
|
#undef DECL_BORROWED_MUT_REF_TYPE_FOR
|
|
|
|
#undef DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR
|
|
|
|
|
2016-11-23 03:35:55 +03:00
|
|
|
#define SERVO_ARC_TYPE(name_, type_) \
|
2016-10-24 12:16:46 +03:00
|
|
|
extern "C" { \
|
|
|
|
void Servo_##name_##_AddRef(type_##Borrowed ptr); \
|
|
|
|
void Servo_##name_##_Release(type_##Borrowed ptr); \
|
|
|
|
} \
|
|
|
|
namespace mozilla { \
|
|
|
|
template<> struct RefPtrTraits<type_> { \
|
|
|
|
static void AddRef(type_* aPtr) { \
|
|
|
|
Servo_##name_##_AddRef(aPtr); \
|
|
|
|
} \
|
|
|
|
static void Release(type_* aPtr) { \
|
|
|
|
Servo_##name_##_Release(aPtr); \
|
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
}
|
2016-11-23 03:35:55 +03:00
|
|
|
#include "mozilla/ServoArcTypeList.h"
|
|
|
|
#undef SERVO_ARC_TYPE
|
2016-10-24 12:16:46 +03:00
|
|
|
|
2016-12-01 04:34:54 +03:00
|
|
|
#define DEFINE_BOXED_TYPE(name_, type_) \
|
|
|
|
extern "C" void Servo_##name_##_Drop(type_##Owned ptr); \
|
|
|
|
namespace mozilla { \
|
|
|
|
template<> \
|
|
|
|
class DefaultDelete<type_> \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
void operator()(type_* aPtr) const \
|
|
|
|
{ \
|
|
|
|
Servo_##name_##_Drop(aPtr); \
|
|
|
|
} \
|
|
|
|
}; \
|
2016-10-24 12:16:46 +03:00
|
|
|
}
|
2016-12-01 04:34:54 +03:00
|
|
|
|
|
|
|
DEFINE_BOXED_TYPE(StyleSet, RawServoStyleSet);
|
2017-10-02 13:07:11 +03:00
|
|
|
DEFINE_BOXED_TYPE(SelectorList, RawServoSelectorList);
|
2016-12-01 04:34:54 +03:00
|
|
|
|
|
|
|
#undef DEFINE_BOXED_TYPE
|
2016-10-24 12:16:46 +03:00
|
|
|
|
|
|
|
#endif // mozilla_ServoBindingTypes_h
|