Bug 1319614 - Move Servo Arc types to a list file. r=manishearth

MozReview-Commit-ID: JiLwcmN7Oig

--HG--
extra : rebase_source : 45716e10101ae9e2192db9e8d27481f17d32310e
This commit is contained in:
Xidorn Quan 2016-11-23 11:35:55 +11:00
parent 9418d7464a
commit b329a010de
5 changed files with 39 additions and 52 deletions

View File

@ -0,0 +1,13 @@
/* -*- 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/. */
/* a list of all Servo Arc types used in stylo bindings for preprocessing */
SERVO_ARC_TYPE(CssRules, ServoCssRules)
SERVO_ARC_TYPE(StyleSheet, RawServoStyleSheet)
SERVO_ARC_TYPE(ComputedValues, ServoComputedValues)
SERVO_ARC_TYPE(DeclarationBlock, RawServoDeclarationBlock)
SERVO_ARC_TYPE(StyleRule, RawServoStyleRule)

View File

@ -31,10 +31,6 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong,
ThreadSafeURIHolder* base,
ThreadSafeURIHolder* referrer,
ThreadSafePrincipalHolder* principal)
SERVO_BINDING_FUNC(Servo_StyleSheet_AddRef, void,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSheet_Release, void,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong,
@ -52,8 +48,6 @@ SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
RawServoStyleSheetBorrowed reference)
// CSSRuleList
SERVO_BINDING_FUNC(Servo_CssRules_AddRef, void, ServoCssRulesBorrowed rules)
SERVO_BINDING_FUNC(Servo_CssRules_Release, void, ServoCssRulesBorrowed rules)
SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
ServoCssRulesBorrowed rules,
nsTArrayBorrowed_uintptr_t result)
@ -61,10 +55,6 @@ SERVO_BINDING_FUNC(Servo_CssRules_GetStyleRuleAt, RawServoStyleRuleStrong,
ServoCssRulesBorrowed rules, uint32_t index)
// CSS Rules
SERVO_BINDING_FUNC(Servo_StyleRule_AddRef, void,
RawServoStyleRuleBorrowed rule)
SERVO_BINDING_FUNC(Servo_StyleRule_Release, void,
RawServoStyleRuleBorrowed rule)
SERVO_BINDING_FUNC(Servo_StyleRule_Debug, void,
RawServoStyleRuleBorrowed rule, nsACString* result)
SERVO_BINDING_FUNC(Servo_StyleRule_GetStyle, RawServoDeclarationBlockStrong,
@ -96,10 +86,6 @@ SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty,
RawServoDeclarationBlockStrong)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Clone, RawServoDeclarationBlockStrong,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_AddRef, void,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Release, void,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Equals, bool,
RawServoDeclarationBlockBorrowed a,
RawServoDeclarationBlockBorrowed b)
@ -144,10 +130,6 @@ SERVO_BINDING_FUNC(Servo_ComputedValues_GetForPseudoElement,
RawServoStyleSetBorrowed set, bool is_probe)
SERVO_BINDING_FUNC(Servo_ComputedValues_Inherit, ServoComputedValuesStrong,
ServoComputedValuesBorrowedOrNull parent_style)
SERVO_BINDING_FUNC(Servo_ComputedValues_AddRef, void,
ServoComputedValuesBorrowed computed_values)
SERVO_BINDING_FUNC(Servo_ComputedValues_Release, void,
ServoComputedValuesBorrowed computed_values)
// Initialize Servo components. Should be called exactly once at startup.
SERVO_BINDING_FUNC(Servo_Initialize, void)
@ -182,3 +164,10 @@ SERVO_BINDING_FUNC(Servo_AssertTreeIsClean, void, RawGeckoElementBorrowed root)
ServoComputedValuesBorrowedOrNull computed_values)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
// AddRef / Release functions
#define SERVO_ARC_TYPE(name_, type_) \
SERVO_BINDING_FUNC(Servo_##name_##_AddRef, void, type_##Borrowed) \
SERVO_BINDING_FUNC(Servo_##name_##_Release, void, type_##Borrowed)
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE

View File

@ -10,12 +10,11 @@
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
struct ServoComputedValues;
struct ServoCssRules;
struct RawServoStyleSheet;
struct RawServoStyleSet;
struct RawServoDeclarationBlock;
struct RawServoStyleRule;
#define SERVO_ARC_TYPE(name_, type_) struct type_;
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE
namespace mozilla {
class ServoElementSnapshot;
@ -56,7 +55,7 @@ typedef nsIDocument RawGeckoDocument;
#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_) \
#define SERVO_ARC_TYPE(name_, type_) \
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
DECL_BORROWED_REF_TYPE_FOR(type_) \
struct MOZ_MUST_USE_TYPE type_##Strong \
@ -64,6 +63,8 @@ typedef nsIDocument RawGeckoDocument;
type_* mPtr; \
already_AddRefed<type_> Consume(); \
};
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE
#define DECL_OWNED_REF_TYPE_FOR(type_) \
typedef type_* type_##Owned; \
@ -75,11 +76,6 @@ typedef nsIDocument RawGeckoDocument;
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(ServoCssRules)
DECL_ARC_REF_TYPE_FOR(RawServoStyleSheet)
DECL_ARC_REF_TYPE_FOR(RawServoDeclarationBlock)
DECL_ARC_REF_TYPE_FOR(RawServoStyleRule)
// 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)
@ -113,7 +109,7 @@ DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSValue)
#undef DECL_BORROWED_MUT_REF_TYPE_FOR
#undef DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR
#define DEFINE_REFPTR_TRAITS(name_, type_) \
#define SERVO_ARC_TYPE(name_, type_) \
extern "C" { \
void Servo_##name_##_AddRef(type_##Borrowed ptr); \
void Servo_##name_##_Release(type_##Borrowed ptr); \
@ -128,14 +124,8 @@ DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSValue)
} \
}; \
}
DEFINE_REFPTR_TRAITS(CssRules, ServoCssRules)
DEFINE_REFPTR_TRAITS(StyleSheet, RawServoStyleSheet)
DEFINE_REFPTR_TRAITS(ComputedValues, ServoComputedValues)
DEFINE_REFPTR_TRAITS(DeclarationBlock, RawServoDeclarationBlock)
DEFINE_REFPTR_TRAITS(StyleRule, RawServoStyleRule)
#undef DEFINE_REFPTR_TRAITS
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE
extern "C" void Servo_StyleSet_Drop(RawServoStyleSetOwned ptr);

View File

@ -36,21 +36,15 @@
using namespace mozilla;
using namespace mozilla::dom;
#define IMPL_STRONG_REF_TYPE_FOR(type_) \
already_AddRefed<type_> \
type_##Strong::Consume() { \
RefPtr<type_> result; \
result.swap(mPtr); \
return result.forget(); \
#define SERVO_ARC_TYPE(name_, type_) \
already_AddRefed<type_> \
type_##Strong::Consume() { \
RefPtr<type_> result; \
result.swap(mPtr); \
return result.forget(); \
}
IMPL_STRONG_REF_TYPE_FOR(ServoComputedValues)
IMPL_STRONG_REF_TYPE_FOR(ServoCssRules)
IMPL_STRONG_REF_TYPE_FOR(RawServoStyleSheet)
IMPL_STRONG_REF_TYPE_FOR(RawServoDeclarationBlock)
IMPL_STRONG_REF_TYPE_FOR(RawServoStyleRule)
#undef IMPL_STRONG_REF_TYPE_FOR
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE
uint32_t
Gecko_ChildrenCount(RawGeckoNodeBorrowed aNode)

View File

@ -93,6 +93,7 @@ EXPORTS.mozilla += [
'LayerAnimationInfo.h',
'RuleNodeCacheConditions.h',
'RuleProcessorCache.h',
'ServoArcTypeList.h',
'ServoBindingList.h',
'ServoBindings.h',
'ServoBindingTypes.h',