зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1311598 part 4 - Split binding types from ServoBindings.h into ServoBindingTypes, and merge ServoBindingHelpers into it. r=heycam
MozReview-Commit-ID: CKvBMOapqlI --HG-- extra : rebase_source : 83531296b4b8a8a9c54f03953cab2a48e8c6cbad extra : source : e1c6c680a4718619e1a4cbecd84cccac4101d69b
This commit is contained in:
Родитель
131121fc77
Коммит
0e7a21831d
|
@ -20,8 +20,8 @@
|
|||
#include "mozilla/EffectCompositor.h"
|
||||
#include "mozilla/KeyframeEffectParams.h"
|
||||
#include "mozilla/LayerAnimationInfo.h" // LayerAnimations::kRecords
|
||||
#include "mozilla/ServoBindingHelpers.h" // RawServoDeclarationBlock and
|
||||
// associated RefPtrTraits
|
||||
#include "mozilla/ServoBindingTypes.h" // RawServoDeclarationBlock and
|
||||
// associated RefPtrTraits
|
||||
#include "mozilla/StyleAnimationValue.h"
|
||||
#include "mozilla/dom/AnimationEffectReadOnly.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "nsIAtom.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/ServoBindingHelpers.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/DeclarationBlockInlines.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/* -*- 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_ServoBindingHelpers_h
|
||||
#define mozilla_ServoBindingHelpers_h
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
#define DEFINE_REFPTR_TRAITS(name_, type_) \
|
||||
template<> \
|
||||
struct RefPtrTraits<type_> \
|
||||
{ \
|
||||
static void AddRef(type_* aPtr) \
|
||||
{ \
|
||||
Servo_##name_##_AddRef(aPtr); \
|
||||
} \
|
||||
static void Release(type_* aPtr) \
|
||||
{ \
|
||||
Servo_##name_##_Release(aPtr); \
|
||||
} \
|
||||
}
|
||||
|
||||
DEFINE_REFPTR_TRAITS(StyleSheet, RawServoStyleSheet);
|
||||
DEFINE_REFPTR_TRAITS(ComputedValues, ServoComputedValues);
|
||||
DEFINE_REFPTR_TRAITS(DeclarationBlock, RawServoDeclarationBlock);
|
||||
|
||||
#undef DEFINE_REFPTR_TRAITS
|
||||
|
||||
template<>
|
||||
class DefaultDelete<RawServoStyleSet>
|
||||
{
|
||||
public:
|
||||
void operator()(RawServoStyleSet* aPtr) const
|
||||
{
|
||||
Servo_StyleSet_Drop(aPtr);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_ServoBindingHelpers_h
|
|
@ -0,0 +1,141 @@
|
|||
/* -*- 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"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
struct ServoComputedValues;
|
||||
struct RawServoStyleSheet;
|
||||
struct RawServoStyleSet;
|
||||
struct RawServoDeclarationBlock;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
class StyleChildrenIterator;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsIDocument;
|
||||
class nsINode;
|
||||
|
||||
using mozilla::dom::StyleChildrenIterator;
|
||||
|
||||
typedef nsINode RawGeckoNode;
|
||||
typedef mozilla::dom::Element RawGeckoElement;
|
||||
typedef nsIDocument RawGeckoDocument;
|
||||
|
||||
// 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;
|
||||
|
||||
#define DECL_ARC_REF_TYPE_FOR(type_) \
|
||||
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
|
||||
DECL_BORROWED_REF_TYPE_FOR(type_) \
|
||||
struct MOZ_MUST_USE_TYPE type_##Strong \
|
||||
{ \
|
||||
type_* mPtr; \
|
||||
already_AddRefed<type_> Consume(); \
|
||||
};
|
||||
|
||||
#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_)
|
||||
|
||||
DECL_ARC_REF_TYPE_FOR(ServoComputedValues)
|
||||
DECL_ARC_REF_TYPE_FOR(RawServoStyleSheet)
|
||||
DECL_ARC_REF_TYPE_FOR(RawServoDeclarationBlock)
|
||||
// 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)
|
||||
DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
|
||||
DECL_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
|
||||
|
||||
// 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)
|
||||
DECL_BORROWED_MUT_REF_TYPE_FOR(StyleChildrenIterator)
|
||||
|
||||
#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
|
||||
|
||||
#define DEFINE_REFPTR_TRAITS(name_, type_) \
|
||||
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); \
|
||||
} \
|
||||
}; \
|
||||
}
|
||||
|
||||
DEFINE_REFPTR_TRAITS(StyleSheet, RawServoStyleSheet)
|
||||
DEFINE_REFPTR_TRAITS(ComputedValues, ServoComputedValues)
|
||||
DEFINE_REFPTR_TRAITS(DeclarationBlock, RawServoDeclarationBlock)
|
||||
|
||||
#undef DEFINE_REFPTR_TRAITS
|
||||
|
||||
extern "C" void Servo_StyleSet_Drop(RawServoStyleSetOwned ptr);
|
||||
|
||||
namespace mozilla {
|
||||
template<>
|
||||
class DefaultDelete<RawServoStyleSet>
|
||||
{
|
||||
public:
|
||||
void operator()(RawServoStyleSet* aPtr) const
|
||||
{
|
||||
Servo_StyleSet_Drop(aPtr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // mozilla_ServoBindingTypes_h
|
|
@ -7,18 +7,14 @@
|
|||
#ifndef mozilla_ServoBindings_h
|
||||
#define mozilla_ServoBindings_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mozilla/ServoTypes.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/ServoElementSnapshot.h"
|
||||
#include "mozilla/css/SheetParsingMode.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsStyleCoord.h"
|
||||
#include "nsStyleStruct.h"
|
||||
#include "stdint.h"
|
||||
|
||||
/*
|
||||
* API for Servo to access Gecko data structures. This file must compile as valid
|
||||
|
@ -38,99 +34,13 @@ namespace mozilla {
|
|||
}
|
||||
using mozilla::FontFamilyList;
|
||||
using mozilla::FontFamilyType;
|
||||
using mozilla::dom::Element;
|
||||
using mozilla::ServoElementSnapshot;
|
||||
struct ServoComputedValues;
|
||||
struct RawServoStyleSheet;
|
||||
struct RawServoStyleSet;
|
||||
class nsHTMLCSSStyleSheet;
|
||||
struct nsStyleList;
|
||||
struct nsStyleImage;
|
||||
struct nsStyleGradientStop;
|
||||
class nsStyleGradient;
|
||||
class nsStyleCoord;
|
||||
struct nsStyleDisplay;
|
||||
struct RawServoDeclarationBlock;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class StyleChildrenIterator;
|
||||
}
|
||||
}
|
||||
|
||||
using mozilla::dom::StyleChildrenIterator;
|
||||
|
||||
// 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;
|
||||
|
||||
#define DECL_ARC_REF_TYPE_FOR(type_) \
|
||||
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
|
||||
DECL_BORROWED_REF_TYPE_FOR(type_) \
|
||||
struct MOZ_MUST_USE_TYPE type_##Strong \
|
||||
{ \
|
||||
type_* mPtr; \
|
||||
already_AddRefed<type_> Consume(); \
|
||||
};
|
||||
|
||||
#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_)
|
||||
|
||||
DECL_ARC_REF_TYPE_FOR(ServoComputedValues)
|
||||
DECL_ARC_REF_TYPE_FOR(RawServoStyleSheet)
|
||||
DECL_ARC_REF_TYPE_FOR(RawServoDeclarationBlock)
|
||||
// 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)
|
||||
DECL_NULLABLE_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
|
||||
DECL_OWNED_REF_TYPE_FOR(StyleChildrenIterator)
|
||||
|
||||
// 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)
|
||||
DECL_BORROWED_MUT_REF_TYPE_FOR(StyleChildrenIterator)
|
||||
|
||||
#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
|
||||
|
||||
|
||||
#define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \
|
||||
void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \
|
||||
|
@ -348,7 +258,6 @@ NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
|
|||
|
||||
// Style-struct management.
|
||||
#define STYLE_STRUCT(name, checkdata_cb) \
|
||||
struct nsStyle##name; \
|
||||
void Gecko_Construct_nsStyle##name(nsStyle##name* ptr); \
|
||||
void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
|
||||
const nsStyle##name* other); \
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/ServoBindingHelpers.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/ServoElementSnapshot.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/SheetType.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "mozilla/dom/SRIMetadata.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/ServoBindingHelpers.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/StyleSheetInfo.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef mozilla_StyleContextSource_h
|
||||
#define mozilla_StyleContextSource_h
|
||||
|
||||
#include "mozilla/ServoBindingHelpers.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "nsRuleNode.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -93,9 +93,9 @@ EXPORTS.mozilla += [
|
|||
'LayerAnimationInfo.h',
|
||||
'RuleNodeCacheConditions.h',
|
||||
'RuleProcessorCache.h',
|
||||
'ServoBindingHelpers.h',
|
||||
'ServoBindingList.h',
|
||||
'ServoBindings.h',
|
||||
'ServoBindingTypes.h',
|
||||
'ServoDeclarationBlock.h',
|
||||
'ServoElementSnapshot.h',
|
||||
'ServoStyleSet.h',
|
||||
|
|
|
@ -52,11 +52,6 @@ class ImageTracker;
|
|||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
typedef nsINode RawGeckoNode;
|
||||
typedef mozilla::dom::Element RawGeckoElement;
|
||||
typedef nsIDocument RawGeckoDocument;
|
||||
struct ServoNodeData;
|
||||
|
||||
// Includes nsStyleStructID.
|
||||
#include "nsStyleStructFwd.h"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче