Bug 1538694 - Cleanup refcounted types. r=boris

And make the handling of ComputedStyle more similar to these.

Differential Revision: https://phabricator.services.mozilla.com/D24703

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-03-26 18:16:01 +00:00
Родитель 72c43d2bf2
Коммит b3c3646515
13 изменённых файлов: 163 добавлений и 250 удалений

Просмотреть файл

@ -34,8 +34,6 @@ class nsWindowSizes;
#undef STYLE_STRUCT
extern "C" {
void Servo_ComputedStyle_AddRef(const mozilla::ComputedStyle* aStyle);
void Servo_ComputedStyle_Release(const mozilla::ComputedStyle* aStyle);
void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle*);
}
@ -91,9 +89,6 @@ class ComputedStyle {
Bit Bits() const { return static_cast<Bit>(mSource.flags.mFlags); }
void AddRef() { Servo_ComputedStyle_AddRef(this); }
void Release() { Servo_ComputedStyle_Release(this); }
// Return the ComputedStyle whose style data should be used for the R,
// G, and B components of color, background-color, and border-*-color
// if RelevantLinkIsVisited().

Просмотреть файл

@ -148,15 +148,16 @@ class DeclarationBlock final {
return reinterpret_cast<RawServoDeclarationBlock* const*>(&mRaw);
}
const RawServoDeclarationBlockStrong* RefRawStrong() const {
const StyleStrong<RawServoDeclarationBlock>* RefRawStrong() const {
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlock*),
"RefPtr should just be a pointer");
static_assert(
sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlockStrong),
sizeof(StyleStrong<RawServoDeclarationBlock>),
"RawServoDeclarationBlockStrong should be the same as RefPtr");
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&mRaw);
return reinterpret_cast<const StyleStrong<RawServoDeclarationBlock>*>(
&mRaw);
}
void ToString(nsAString& aResult) const {

Просмотреть файл

@ -85,16 +85,6 @@ using namespace mozilla;
using namespace mozilla::css;
using namespace mozilla::dom;
#define SERVO_ARC_TYPE(name_, type_) \
already_AddRefed<type_> type_##Strong::Consume() { \
RefPtr<type_> result; \
result.swap(mPtr); \
return result.forget(); \
}
#include "mozilla/ServoArcTypeList.h"
SERVO_ARC_TYPE(ComputedStyle, ComputedStyle)
#undef SERVO_ARC_TYPE
// Definitions of the global traversal stats.
bool ServoTraversalStatistics::sActive = false;
ServoTraversalStatistics ServoTraversalStatistics::sSingleton;
@ -355,7 +345,7 @@ bool Gecko_HaveSeenPtr(SeenPtrs* aTable, const void* aPtr) {
return aTable->HaveSeenPtr(aPtr);
}
const RawServoDeclarationBlockStrong* Gecko_GetStyleAttrDeclarationBlock(
const StyleStrong<RawServoDeclarationBlock>* Gecko_GetStyleAttrDeclarationBlock(
const Element* aElement) {
DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
if (!decl) {
@ -372,15 +362,15 @@ void Gecko_UnsetDirtyStyleAttr(const Element* aElement) {
decl->UnsetDirty();
}
static const RawServoDeclarationBlockStrong* AsRefRawStrong(
static const StyleStrong<RawServoDeclarationBlock>* AsRefRawStrong(
const RefPtr<RawServoDeclarationBlock>& aDecl) {
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
sizeof(RawServoDeclarationBlockStrong),
sizeof(StyleStrong<RawServoDeclarationBlock>),
"RefPtr should just be a pointer");
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&aDecl);
return reinterpret_cast<const StyleStrong<RawServoDeclarationBlock>*>(&aDecl);
}
const RawServoDeclarationBlockStrong*
const StyleStrong<RawServoDeclarationBlock>*
Gecko_GetHTMLPresentationAttrDeclarationBlock(const Element* aElement) {
const nsMappedAttributes* attrs = aElement->GetMappedAttributes();
if (!attrs) {
@ -396,8 +386,8 @@ Gecko_GetHTMLPresentationAttrDeclarationBlock(const Element* aElement) {
return AsRefRawStrong(attrs->GetServoStyle());
}
const RawServoDeclarationBlockStrong* Gecko_GetExtraContentStyleDeclarations(
const Element* aElement) {
const StyleStrong<RawServoDeclarationBlock>*
Gecko_GetExtraContentStyleDeclarations(const Element* aElement) {
if (!aElement->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th)) {
return nullptr;
}
@ -410,7 +400,7 @@ const RawServoDeclarationBlockStrong* Gecko_GetExtraContentStyleDeclarations(
return nullptr;
}
const RawServoDeclarationBlockStrong*
const StyleStrong<RawServoDeclarationBlock>*
Gecko_GetUnvisitedLinkAttrDeclarationBlock(const Element* aElement) {
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
if (!sheet) {
@ -448,8 +438,8 @@ void Gecko_StyleSheet_Release(const StyleSheet* aSheet) {
const_cast<StyleSheet*>(aSheet)->Release();
}
const RawServoDeclarationBlockStrong* Gecko_GetVisitedLinkAttrDeclarationBlock(
const Element* aElement) {
const StyleStrong<RawServoDeclarationBlock>*
Gecko_GetVisitedLinkAttrDeclarationBlock(const Element* aElement) {
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
if (!sheet) {
return nullptr;
@ -458,8 +448,8 @@ const RawServoDeclarationBlockStrong* Gecko_GetVisitedLinkAttrDeclarationBlock(
return AsRefRawStrong(sheet->GetServoVisitedLinkDecl());
}
const RawServoDeclarationBlockStrong* Gecko_GetActiveLinkAttrDeclarationBlock(
const Element* aElement) {
const StyleStrong<RawServoDeclarationBlock>*
Gecko_GetActiveLinkAttrDeclarationBlock(const Element* aElement) {
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
if (!sheet) {
return nullptr;
@ -1641,7 +1631,7 @@ void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* aDst,
aDst->mContextPropsBits = aSrc->mContextPropsBits;
}
URLValue* Gecko_URLValue_Create(RawServoCssUrlDataStrong aCssUrl,
URLValue* Gecko_URLValue_Create(StyleStrong<RawServoCssUrlData> aCssUrl,
CORSMode aCORSMode) {
RefPtr<URLValue> url = new URLValue(aCssUrl.Consume(), aCORSMode);
return url.forget().take();
@ -2060,7 +2050,8 @@ GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext* aPresContext,
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(SheetLoadDataHolder, SheetLoadDataHolder);
void Gecko_StyleSheet_FinishAsyncParse(
SheetLoadDataHolder* aData, RawServoStyleSheetContentsStrong aSheetContents,
SheetLoadDataHolder* aData,
StyleStrong<RawServoStyleSheetContents> aSheetContents,
StyleOwnedOrNull<StyleUseCounters> aUseCounters) {
UniquePtr<StyleUseCounters> useCounters = aUseCounters.Consume();
RefPtr<SheetLoadDataHolder> loadData = aData;
@ -2128,8 +2119,8 @@ static already_AddRefed<StyleSheet> LoadImportSheet(
StyleSheet* Gecko_LoadStyleSheet(Loader* aLoader, StyleSheet* aParent,
SheetLoadData* aParentLoadData,
LoaderReusableStyleSheets* aReusableSheets,
RawServoCssUrlDataStrong aCssUrl,
RawServoMediaListStrong aMediaList) {
StyleStrong<RawServoCssUrlData> aCssUrl,
StyleStrong<RawServoMediaList> aMediaList) {
MOZ_ASSERT(NS_IsMainThread());
// The CORS mode in the URLValue is irrelevant here.
@ -2141,9 +2132,9 @@ StyleSheet* Gecko_LoadStyleSheet(Loader* aLoader, StyleSheet* aParent,
}
void Gecko_LoadStyleSheetAsync(SheetLoadDataHolder* aParentData,
RawServoCssUrlDataStrong aCssUrl,
RawServoMediaListStrong aMediaList,
RawServoImportRuleStrong aImportRule) {
StyleStrong<RawServoCssUrlData> aCssUrl,
StyleStrong<RawServoMediaList> aMediaList,
StyleStrong<RawServoImportRule> aImportRule) {
RefPtr<SheetLoadDataHolder> loadData = aParentData;
// The CORS mode in the URLValue is irrelevant here.
// (CORS_NONE is used for all imported sheets in Load::LoadChildSheet.)

Просмотреть файл

@ -109,19 +109,20 @@ NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
void Gecko_StyleSheet_FinishAsyncParse(
mozilla::css::SheetLoadDataHolder* data,
RawServoStyleSheetContentsStrong sheet_contents,
mozilla::StyleStrong<RawServoStyleSheetContents> sheet_contents,
mozilla::StyleOwnedOrNull<StyleUseCounters> use_counters);
mozilla::StyleSheet* Gecko_LoadStyleSheet(
mozilla::css::Loader* loader, mozilla::StyleSheet* parent,
mozilla::css::SheetLoadData* parent_load_data,
mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
RawServoCssUrlDataStrong url, RawServoMediaListStrong media_list);
mozilla::StyleStrong<RawServoCssUrlData> url,
mozilla::StyleStrong<RawServoMediaList> media_list);
void Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder* parent_data,
RawServoCssUrlDataStrong,
RawServoMediaListStrong,
RawServoImportRuleStrong);
mozilla::StyleStrong<RawServoCssUrlData>,
mozilla::StyleStrong<RawServoMediaList>,
mozilla::StyleStrong<RawServoImportRule>);
// Selector Matching.
uint64_t Gecko_ElementState(const mozilla::dom::Element*);
@ -170,27 +171,27 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
// Style attributes.
const RawServoDeclarationBlockStrong* Gecko_GetStyleAttrDeclarationBlock(
const mozilla::dom::Element* element);
const mozilla::StyleStrong<RawServoDeclarationBlock>*
Gecko_GetStyleAttrDeclarationBlock(const mozilla::dom::Element* element);
void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element* element);
const RawServoDeclarationBlockStrong*
const mozilla::StyleStrong<RawServoDeclarationBlock>*
Gecko_GetHTMLPresentationAttrDeclarationBlock(
const mozilla::dom::Element* element);
const RawServoDeclarationBlockStrong* Gecko_GetExtraContentStyleDeclarations(
const mozilla::dom::Element* element);
const mozilla::StyleStrong<RawServoDeclarationBlock>*
Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element* element);
const RawServoDeclarationBlockStrong*
const mozilla::StyleStrong<RawServoDeclarationBlock>*
Gecko_GetUnvisitedLinkAttrDeclarationBlock(
const mozilla::dom::Element* element);
const RawServoDeclarationBlockStrong* Gecko_GetVisitedLinkAttrDeclarationBlock(
const mozilla::dom::Element* element);
const mozilla::StyleStrong<RawServoDeclarationBlock>*
Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
const RawServoDeclarationBlockStrong* Gecko_GetActiveLinkAttrDeclarationBlock(
const mozilla::dom::Element* element);
const mozilla::StyleStrong<RawServoDeclarationBlock>*
Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
// Visited handling.
@ -567,8 +568,8 @@ void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
const nsStyleSVG* src);
mozilla::css::URLValue* Gecko_URLValue_Create(RawServoCssUrlDataStrong url,
mozilla::CORSMode aCORSMode);
mozilla::css::URLValue* Gecko_URLValue_Create(
mozilla::StyleStrong<RawServoCssUrlData> url, mozilla::CORSMode aCORSMode);
size_t Gecko_URLValue_SizeOfIncludingThis(mozilla::css::URLValue* url);

Просмотреть файл

@ -37,9 +37,9 @@ SERVO_ARC_TYPE(PageRule, RawServoPageRule)
SERVO_ARC_TYPE(SupportsRule, RawServoSupportsRule)
SERVO_ARC_TYPE(DocumentRule, RawServoMozDocumentRule)
SERVO_ARC_TYPE(FontFeatureValuesRule, RawServoFontFeatureValuesRule)
SERVO_ARC_TYPE(RuleNode, RawServoRuleNode)
SERVO_ARC_TYPE(FontFaceRule, RawServoFontFaceRule)
SERVO_ARC_TYPE(CounterStyleRule, RawServoCounterStyleRule)
SERVO_ARC_TYPE(CssUrlData, RawServoCssUrlData)
SERVO_ARC_TYPE(Quotes, RawServoQuotes)
// clang-format on

Просмотреть файл

@ -144,10 +144,6 @@ class Element;
} // namespace mozilla
#define SERVO_ARC_TYPE(name_, type_) \
struct MOZ_MUST_USE_TYPE type_##Strong { \
type_* mPtr; \
already_AddRefed<type_> Consume(); \
}; \
extern "C" { \
void Servo_##name_##_AddRef(const type_*); \
void Servo_##name_##_Release(const type_*); \
@ -160,6 +156,7 @@ class Element;
}; \
}
#include "mozilla/ServoArcTypeList.h"
SERVO_ARC_TYPE(ComputedStyle, mozilla::ComputedStyle)
#undef SERVO_ARC_TYPE
// See the comment in ServoBindings.h about the same.
@ -195,11 +192,4 @@ SERVO_BOXED_TYPE(UseCounters, StyleUseCounters)
struct RawServoAnimationValueTable;
struct RawServoAnimationValueMap;
struct MOZ_MUST_USE_TYPE ComputedStyleStrong {
mozilla::ComputedStyle* mPtr;
already_AddRefed<mozilla::ComputedStyle> Consume();
};
#undef DECL_ARC_REF_TYPE_FOR
#endif // mozilla_ServoBindingTypes_h

Просмотреть файл

@ -72,14 +72,15 @@ size_t Servo_Element_SizeOfExcludingThisAndCVs(
bool Servo_Element_HasPrimaryComputedValues(const mozilla::dom::Element* node);
ComputedStyleStrong Servo_Element_GetPrimaryComputedValues(
const mozilla::dom::Element* node);
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_Element_GetPrimaryComputedValues(const mozilla::dom::Element* node);
bool Servo_Element_HasPseudoComputedValues(const mozilla::dom::Element* node,
size_t index);
ComputedStyleStrong Servo_Element_GetPseudoComputedValues(
const mozilla::dom::Element* node, size_t index);
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_Element_GetPseudoComputedValues(const mozilla::dom::Element* node,
size_t index);
bool Servo_Element_IsDisplayNone(const mozilla::dom::Element* element);
bool Servo_Element_IsDisplayContents(const mozilla::dom::Element* element);
@ -94,7 +95,7 @@ void Servo_InvalidateStyleForDocStateChanges(
// Styleset and Stylesheet management
RawServoStyleSheetContentsStrong Servo_StyleSheet_FromUTF8Bytes(
mozilla::StyleStrong<RawServoStyleSheetContents> Servo_StyleSheet_FromUTF8Bytes(
mozilla::css::Loader* loader, mozilla::StyleSheet* gecko_stylesheet,
mozilla::css::SheetLoadData* load_data, const nsACString* bytes,
mozilla::css::SheetParsingMode parsing_mode,
@ -109,15 +110,15 @@ void Servo_StyleSheet_FromUTF8BytesAsync(
mozilla::css::SheetParsingMode parsing_mode, uint32_t line_number_offset,
nsCompatibility quirks_mode, bool should_record_use_counters);
RawServoStyleSheetContentsStrong Servo_StyleSheet_Empty(
mozilla::StyleStrong<RawServoStyleSheetContents> Servo_StyleSheet_Empty(
mozilla::css::SheetParsingMode parsing_mode);
bool Servo_StyleSheet_HasRules(const RawServoStyleSheetContents* sheet);
ServoCssRulesStrong Servo_StyleSheet_GetRules(
mozilla::StyleStrong<ServoCssRules> Servo_StyleSheet_GetRules(
const RawServoStyleSheetContents* sheet);
RawServoStyleSheetContentsStrong Servo_StyleSheet_Clone(
mozilla::StyleStrong<RawServoStyleSheetContents> Servo_StyleSheet_Clone(
const RawServoStyleSheetContents* sheet,
const mozilla::StyleSheet* reference_sheet);
@ -187,7 +188,8 @@ const RawServoCounterStyleRule* Servo_StyleSet_GetCounterStyleRule(
gfxFontFeatureValueSet* Servo_StyleSet_BuildFontFeatureValueSet(
const RawServoStyleSet* set);
ComputedStyleStrong Servo_StyleSet_ResolveForDeclarations(
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_StyleSet_ResolveForDeclarations(
const RawServoStyleSet* set, const mozilla::ComputedStyle* parent_style,
const RawServoDeclarationBlock* declarations);
@ -247,10 +249,6 @@ size_t Servo_AuthorStyles_SizeOfIncludingThis(
mozilla::MallocSizeOf malloc_enclosing_size_of,
const RawServoAuthorStyles* self);
void Servo_ComputedStyle_AddRef(const mozilla::ComputedStyle* ctx);
void Servo_ComputedStyle_Release(const mozilla::ComputedStyle* ctx);
bool Servo_StyleSet_MightHaveAttributeDependency(
const RawServoStyleSet* set, const mozilla::dom::Element* element,
nsAtom* local_name);
@ -282,15 +280,16 @@ nsresult Servo_CssRules_DeleteRule(const ServoCssRules* rules, uint32_t index);
void Servo_##type_##_Debug(const RawServo##type_*, nsACString* result); \
void Servo_##type_##_GetCssText(const RawServo##type_*, nsAString* result);
#define BASIC_RULE_FUNCS(type_) \
RawServo##type_##RuleStrong Servo_CssRules_Get##type_##RuleAt( \
const ServoCssRules* rules, uint32_t index, uint32_t* line, \
uint32_t* column); \
#define BASIC_RULE_FUNCS(type_) \
mozilla::StyleStrong<RawServo##type_##Rule> \
Servo_CssRules_Get##type_##RuleAt(const ServoCssRules* rules, \
uint32_t index, uint32_t* line, \
uint32_t* column); \
BASIC_RULE_FUNCS_WITHOUT_GETTER(type_##Rule)
#define GROUP_RULE_FUNCS(type_) \
BASIC_RULE_FUNCS(type_) \
ServoCssRulesStrong Servo_##type_##Rule_GetRules( \
#define GROUP_RULE_FUNCS(type_) \
BASIC_RULE_FUNCS(type_) \
mozilla::StyleStrong<ServoCssRules> Servo_##type_##Rule_GetRules( \
const RawServo##type_##Rule* rule);
BASIC_RULE_FUNCS(Style)
@ -312,7 +311,7 @@ BASIC_RULE_FUNCS(CounterStyle)
using Matrix4x4Components = float[16];
RawServoDeclarationBlockStrong Servo_StyleRule_GetStyle(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_StyleRule_GetStyle(
const RawServoStyleRule*);
void Servo_StyleRule_SetStyle(const RawServoStyleRule* rule,
@ -355,7 +354,7 @@ void Servo_Keyframe_GetKeyText(const RawServoKeyframe* keyframe,
bool Servo_Keyframe_SetKeyText(const RawServoKeyframe* keyframe,
const nsACString* text);
RawServoDeclarationBlockStrong Servo_Keyframe_GetStyle(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_Keyframe_GetStyle(
const RawServoKeyframe* keyframe);
void Servo_Keyframe_SetStyle(const RawServoKeyframe* keyframe,
@ -369,7 +368,7 @@ void Servo_KeyframesRule_SetName(const RawServoKeyframesRule* rule,
uint32_t Servo_KeyframesRule_GetCount(const RawServoKeyframesRule* rule);
RawServoKeyframeStrong Servo_KeyframesRule_GetKeyframeAt(
mozilla::StyleStrong<RawServoKeyframe> Servo_KeyframesRule_GetKeyframeAt(
const RawServoKeyframesRule* rule, uint32_t index, uint32_t* line,
uint32_t* column);
@ -385,12 +384,13 @@ bool Servo_KeyframesRule_AppendRule(const RawServoKeyframesRule* rule,
void Servo_KeyframesRule_DeleteRule(const RawServoKeyframesRule* rule,
uint32_t index);
RawServoMediaListStrong Servo_MediaRule_GetMedia(const RawServoMediaRule* rule);
mozilla::StyleStrong<RawServoMediaList> Servo_MediaRule_GetMedia(
const RawServoMediaRule* rule);
nsAtom* Servo_NamespaceRule_GetPrefix(const RawServoNamespaceRule* rule);
nsAtom* Servo_NamespaceRule_GetURI(const RawServoNamespaceRule* rule);
RawServoDeclarationBlockStrong Servo_PageRule_GetStyle(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_PageRule_GetStyle(
const RawServoPageRule* rule);
void Servo_PageRule_SetStyle(const RawServoPageRule* rule,
@ -408,9 +408,9 @@ void Servo_FontFeatureValuesRule_GetFontFamily(
void Servo_FontFeatureValuesRule_GetValueText(
const RawServoFontFeatureValuesRule* rule, nsAString* result);
RawServoFontFaceRuleStrong Servo_FontFaceRule_CreateEmpty();
mozilla::StyleStrong<RawServoFontFaceRule> Servo_FontFaceRule_CreateEmpty();
RawServoFontFaceRuleStrong Servo_FontFaceRule_Clone(
mozilla::StyleStrong<RawServoFontFaceRule> Servo_FontFaceRule_Clone(
const RawServoFontFaceRule* rule);
void Servo_FontFaceRule_GetSourceLocation(const RawServoFontFaceRule* rule,
@ -503,7 +503,7 @@ bool Servo_CounterStyleRule_SetDescriptor(const RawServoCounterStyleRule* rule,
// Animations API
RawServoDeclarationBlockStrong Servo_ParseProperty(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_ParseProperty(
nsCSSPropertyID property, const nsACString* value,
mozilla::URLExtraData* data, mozilla::ParsingMode parsing_mode,
nsCompatibility quirks_mode, mozilla::css::Loader* loader);
@ -521,7 +521,8 @@ void Servo_GetComputedKeyframeValues(
const RawServoStyleSet* set,
nsTArray<mozilla::ComputedKeyframeValues>* result);
RawServoAnimationValueStrong Servo_ComputedValues_ExtractAnimationValue(
mozilla::StyleStrong<RawServoAnimationValue>
Servo_ComputedValues_ExtractAnimationValue(
const mozilla::ComputedStyle* computed_values, nsCSSPropertyID property);
bool Servo_ComputedValues_SpecifiesAnimationsOrTransitions(
@ -548,21 +549,21 @@ void Servo_GetAnimationValues(
// AnimationValues handling
RawServoAnimationValueStrong Servo_AnimationValues_Interpolate(
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_Interpolate(
const RawServoAnimationValue* from, const RawServoAnimationValue* to,
double progress);
bool Servo_AnimationValues_IsInterpolable(const RawServoAnimationValue* from,
const RawServoAnimationValue* to);
RawServoAnimationValueStrong Servo_AnimationValues_Add(
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_Add(
const RawServoAnimationValue* a, const RawServoAnimationValue* b);
RawServoAnimationValueStrong Servo_AnimationValues_Accumulate(
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_Accumulate(
const RawServoAnimationValue* a, const RawServoAnimationValue* b,
uint64_t count);
RawServoAnimationValueStrong Servo_AnimationValues_GetZeroValue(
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_GetZeroValue(
const RawServoAnimationValue* value_to_match);
double Servo_AnimationValues_ComputeDistance(const RawServoAnimationValue* from,
@ -574,38 +575,40 @@ void Servo_AnimationValue_Serialize(const RawServoAnimationValue* value,
nscolor Servo_AnimationValue_GetColor(const RawServoAnimationValue* value,
nscolor foregroundColor);
RawServoAnimationValueStrong Servo_AnimationValue_Color(nsCSSPropertyID,
nscolor);
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Color(
nsCSSPropertyID, nscolor);
float Servo_AnimationValue_GetOpacity(const RawServoAnimationValue* value);
RawServoAnimationValueStrong Servo_AnimationValue_Opacity(float);
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Opacity(
float);
nsCSSPropertyID Servo_AnimationValue_GetTransform(
const RawServoAnimationValue* value, RefPtr<nsCSSValueSharedList>* list);
RawServoAnimationValueStrong Servo_AnimationValue_Transform(
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Transform(
nsCSSPropertyID property, const nsCSSValueSharedList& list);
bool Servo_AnimationValue_DeepEqual(const RawServoAnimationValue*,
const RawServoAnimationValue*);
RawServoDeclarationBlockStrong Servo_AnimationValue_Uncompute(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_AnimationValue_Uncompute(
const RawServoAnimationValue* value);
RawServoAnimationValueStrong Servo_AnimationValue_Compute(
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Compute(
const mozilla::dom::Element* element,
const RawServoDeclarationBlock* declarations,
const mozilla::ComputedStyle* style, const RawServoStyleSet* raw_data);
// Style attribute
RawServoDeclarationBlockStrong Servo_ParseStyleAttribute(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_ParseStyleAttribute(
const nsACString* data, mozilla::URLExtraData* extra_data,
nsCompatibility quirks_mode, mozilla::css::Loader* loader);
RawServoDeclarationBlockStrong Servo_DeclarationBlock_CreateEmpty();
mozilla::StyleStrong<RawServoDeclarationBlock>
Servo_DeclarationBlock_CreateEmpty();
RawServoDeclarationBlockStrong Servo_DeclarationBlock_Clone(
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_DeclarationBlock_Clone(
const RawServoDeclarationBlock* declarations);
bool Servo_DeclarationBlock_Equals(const RawServoDeclarationBlock* a,
@ -683,7 +686,7 @@ void Servo_AnimationCompose(
// segment endpoints and the supplied iteration composite mode.
// The caller is responsible for providing an underlying value and
// last value in all situations where there are needed.
RawServoAnimationValueStrong Servo_ComposeAnimationSegment(
mozilla::StyleStrong<RawServoAnimationValue> Servo_ComposeAnimationSegment(
const mozilla::AnimationPropertySegment* animation_segment,
const RawServoAnimationValue* underlying_value,
const RawServoAnimationValue* last_value,
@ -754,9 +757,9 @@ void Servo_DeclarationBlock_SetBackgroundImage(
// MediaList
RawServoMediaListStrong Servo_MediaList_Create();
mozilla::StyleStrong<RawServoMediaList> Servo_MediaList_Create();
RawServoMediaListStrong Servo_MediaList_DeepClone(
mozilla::StyleStrong<RawServoMediaList> Servo_MediaList_DeepClone(
const RawServoMediaList* list);
bool Servo_MediaList_Matches(const RawServoMediaList* list,
@ -791,11 +794,12 @@ bool Servo_CSSSupports(const nsACString* cond);
// Computed style data
ComputedStyleStrong Servo_ComputedValues_GetForAnonymousBox(
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_ComputedValues_GetForAnonymousBox(
const mozilla::ComputedStyle* parent_style_or_null,
mozilla::PseudoStyleType, const RawServoStyleSet* set);
ComputedStyleStrong Servo_ComputedValues_Inherit(
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ComputedValues_Inherit(
const RawServoStyleSet*, mozilla::PseudoStyleType,
const mozilla::ComputedStyle* parent_style, mozilla::InheritTarget);
@ -825,15 +829,16 @@ void Servo_NoteExplicitHints(const mozilla::dom::Element*, mozilla::RestyleHint,
uint32_t Servo_TakeChangeHint(const mozilla::dom::Element* element,
bool* was_restyled);
ComputedStyleStrong Servo_ResolveStyle(const mozilla::dom::Element* element,
const RawServoStyleSet* set);
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ResolveStyle(
const mozilla::dom::Element* element, const RawServoStyleSet* set);
ComputedStyleStrong Servo_ResolvePseudoStyle(
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ResolvePseudoStyle(
const mozilla::dom::Element* element, mozilla::PseudoStyleType pseudo_type,
bool is_probe, const mozilla::ComputedStyle* inherited_style,
const RawServoStyleSet* set);
ComputedStyleStrong Servo_ComputedValues_ResolveXULTreePseudoStyle(
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_ComputedValues_ResolveXULTreePseudoStyle(
const mozilla::dom::Element* element, nsAtom* pseudo_tag,
const mozilla::ComputedStyle* inherited_style,
const mozilla::AtomArray* input_word, const RawServoStyleSet* set);
@ -855,14 +860,14 @@ bool Servo_HasAuthorSpecifiedRules(const RawServoStyleSet* set,
// The tree must be in a consistent state such that a normal traversal could be
// performed, and this function maintains that invariant.
ComputedStyleStrong Servo_ResolveStyleLazily(
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ResolveStyleLazily(
const mozilla::dom::Element* element, mozilla::PseudoStyleType pseudo_type,
mozilla::StyleRuleInclusion rule_inclusion,
const mozilla::ServoElementSnapshotTable* snapshots,
const RawServoStyleSet* set);
// Reparents style to the new parents.
ComputedStyleStrong Servo_ReparentStyle(
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ReparentStyle(
const mozilla::ComputedStyle* style_to_reparent,
const mozilla::ComputedStyle* parent_style,
const mozilla::ComputedStyle* parent_style_ignoring_first_line,
@ -889,13 +894,15 @@ bool Servo_IsWorkerThread();
void Servo_MaybeGCRuleTree(const RawServoStyleSet* set);
// Returns computed values for the given element without any animations rules.
ComputedStyleStrong Servo_StyleSet_GetBaseComputedValuesForElement(
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_StyleSet_GetBaseComputedValuesForElement(
const RawServoStyleSet* set, const mozilla::dom::Element* element,
const mozilla::ComputedStyle* existing_style,
const mozilla::ServoElementSnapshotTable* snapshots);
// Returns computed values for the given element by adding an animation value.
ComputedStyleStrong Servo_StyleSet_GetComputedValuesByAddingAnimation(
mozilla::StyleStrong<mozilla::ComputedStyle>
Servo_StyleSet_GetComputedValuesByAddingAnimation(
const RawServoStyleSet* set, const mozilla::dom::Element* element,
const mozilla::ComputedStyle* existing_style,
const mozilla::ServoElementSnapshotTable* snapshots,
@ -988,20 +995,13 @@ bool Servo_IsCssPropertyRecordedInUseCounter(const StyleUseCounters*,
const nsACString* property,
bool* out_known_prop);
RawServoQuotesStrong Servo_Quotes_GetInitialValue();
mozilla::StyleStrong<RawServoQuotes> Servo_Quotes_GetInitialValue();
bool Servo_Quotes_Equal(const RawServoQuotes* a, RawServoQuotes* b);
void Servo_Quotes_GetQuote(const RawServoQuotes* quotes, int32_t depth,
mozilla::StyleContentType quote_type,
nsAString* result);
// AddRef / Release functions
#define SERVO_ARC_TYPE(name_, type_) \
void Servo_##name_##_AddRef(const type_*); \
void Servo_##name_##_Release(const type_*);
#include "mozilla/ServoArcTypeList.h"
#undef SERVO_ARC_TYPE
} // extern "C"
#pragma GCC diagnostic pop

Просмотреть файл

@ -456,6 +456,7 @@ cbindgen-types = [
{ gecko = "StyleMozListReversed", servo = "values::computed::MozListReversed" },
{ gecko = "StyleOwned", servo = "gecko_bindings::sugar::ownership::Owned" },
{ gecko = "StyleOwnedOrNull", servo = "gecko_bindings::sugar::ownership::OwnedOrNull" },
{ gecko = "StyleStrong", servo = "gecko_bindings::sugar::ownership::Strong" },
]
mapped-generic-types = [

Просмотреть файл

@ -220,44 +220,6 @@ mod bindings {
.expect("Unable to write output");
}
fn get_types(filename: &str, macro_pat: &str) -> Vec<(String, String)> {
// Read the file
let path = DISTDIR_PATH.join("include/mozilla/").join(filename);
let mut list_file = File::open(path).expect(&format!("Unable to open {}", filename));
let mut content = String::new();
list_file
.read_to_string(&mut content)
.expect(&format!("Failed to read {}", filename));
// Remove comments
let block_comment_re = Regex::new(r#"(?s)/\*.*?\*/"#).unwrap();
let line_comment_re = Regex::new(r#"//.*"#).unwrap();
let content = block_comment_re.replace_all(&content, "");
let content = line_comment_re.replace_all(&content, "");
// Extract the list
let re_string = format!(r#"^({})\(.+,\s*(\w+)\)$"#, macro_pat);
let re = Regex::new(&re_string).unwrap();
content
.lines()
.map(|line| line.trim())
.filter(|line| !line.is_empty())
.map(|line| {
let captures = re
.captures(&line)
.expect(&format!("Unrecognized line in {}: '{}'", filename, line));
let macro_name = captures.get(1).unwrap().as_str().to_string();
let type_name = captures.get(2).unwrap().as_str().to_string();
(macro_name, type_name)
})
.collect()
}
fn get_arc_types() -> Vec<String> {
get_types("ServoArcTypeList.h", "SERVO_ARC_TYPE")
.into_iter()
.map(|(_, type_name)| type_name)
.collect()
}
struct BuilderWithConfig<'a> {
builder: Builder,
config: &'a Table,
@ -434,18 +396,10 @@ mod bindings {
.with_codegen_config(CodegenConfig::FUNCTIONS);
let config = CONFIG["bindings"].as_table().unwrap();
let mut fixups = vec![];
let mut builder = BuilderWithConfig::new(builder, config)
let builder = BuilderWithConfig::new(builder, config)
.handle_common(&mut fixups)
.handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item))
.get_builder();
for ty in get_arc_types().iter() {
builder = builder
.blacklist_type(format!("{}Strong", ty))
.raw_line(format!(
"pub type {0}Strong = ::gecko_bindings::sugar::ownership::Strong<{0}>;",
ty
));
}
write_binding_file(builder, BINDINGS_FILE, &fixups);
}

Просмотреть файл

@ -111,6 +111,7 @@ include = [
"MozListReversed",
"Owned",
"OwnedOrNull",
"Strong",
]
item_types = ["enums", "structs", "typedefs"]
@ -228,3 +229,11 @@ item_types = ["enums", "structs", "typedefs"]
return ret;
}
"""
"Strong" = """
already_AddRefed<GeckoType> Consume() {
already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
ptr = nullptr;
return ret;
}
"""

Просмотреть файл

@ -18,8 +18,6 @@ use crate::gecko_bindings::structs::RawServoMediaRule;
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
use crate::gecko_bindings::structs::RawServoNamespaceRule;
use crate::gecko_bindings::structs::RawServoPageRule;
use crate::gecko_bindings::structs::RawServoRuleNode;
use crate::gecko_bindings::structs::RawServoRuleNodeStrong;
use crate::gecko_bindings::structs::RawServoSupportsRule;
use crate::gecko_bindings::structs::ServoCssRules;
use crate::gecko_bindings::structs::RawServoAnimationValue;
@ -34,7 +32,6 @@ use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use crate::media_queries::MediaList;
use crate::properties::animated_properties::AnimationValue;
use crate::properties::{ComputedValues, PropertyDeclarationBlock};
use crate::rule_tree::StrongRuleNode;
use crate::shared_lock::Locked;
use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
@ -121,31 +118,6 @@ impl_arc_ffi!(CssUrlData => RawServoCssUrlData
impl_arc_ffi!(Box<[QuotePair]> => RawServoQuotes
[Servo_Quotes_AddRef, Servo_Quotes_Release]);
// RuleNode is a Arc-like type but it does not use Arc.
impl StrongRuleNode {
pub fn into_strong(self) -> RawServoRuleNodeStrong {
let ptr = self.ptr();
mem::forget(self);
unsafe { mem::transmute(ptr) }
}
pub fn from_ffi<'a>(ffi: &'a &RawServoRuleNode) -> &'a Self {
unsafe { &*(ffi as *const &RawServoRuleNode as *const StrongRuleNode) }
}
}
#[no_mangle]
pub unsafe extern "C" fn Servo_RuleNode_AddRef(obj: &RawServoRuleNode) {
mem::forget(StrongRuleNode::from_ffi(&obj).clone());
}
#[no_mangle]
pub unsafe extern "C" fn Servo_RuleNode_Release(obj: &RawServoRuleNode) {
let ptr = StrongRuleNode::from_ffi(&obj);
ptr::read(ptr as *const StrongRuleNode);
}
// ComputedStyle is not an opaque type on any side of FFI.
// This means that doing the HasArcFFI type trick is actually unsound,
// since it gives us a way to construct an Arc<ComputedStyle> from

Просмотреть файл

@ -135,12 +135,12 @@ pub unsafe trait HasArcFFI: HasFFI {
}
}
#[repr(C)]
/// Gecko-FFI-safe Arc (T is an ArcInner).
///
/// This can be null.
///
/// Leaks on drop. Please don't drop this.
#[repr(C)]
pub struct Strong<GeckoType> {
ptr: *const GeckoType,
_marker: PhantomData<GeckoType>,

Просмотреть файл

@ -73,7 +73,6 @@ use style::gecko_bindings::structs::AtomArray;
use style::gecko_bindings::structs::PseudoStyleType;
use style::gecko_bindings::structs::CallerType;
use style::gecko_bindings::structs::CompositeOperation;
use style::gecko_bindings::structs::ComputedStyleStrong;
use style::gecko_bindings::structs::DeclarationBlockMutationClosure;
use style::gecko_bindings::structs::IterationCompositeOperation;
use style::gecko_bindings::structs::Loader;
@ -362,7 +361,7 @@ pub extern "C" fn Servo_AnimationValues_Interpolate(
from: &RawServoAnimationValue,
to: &RawServoAnimationValue,
progress: f64,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let from_value = AnimationValue::as_arc(&from);
let to_value = AnimationValue::as_arc(&to);
if let Ok(value) = from_value.animate(to_value, Procedure::Interpolate { progress }) {
@ -388,7 +387,7 @@ pub extern "C" fn Servo_AnimationValues_IsInterpolable(
pub extern "C" fn Servo_AnimationValues_Add(
a: &RawServoAnimationValue,
b: &RawServoAnimationValue,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let a_value = AnimationValue::as_arc(&a);
let b_value = AnimationValue::as_arc(&b);
if let Ok(value) = a_value.animate(b_value, Procedure::Add) {
@ -403,7 +402,7 @@ pub extern "C" fn Servo_AnimationValues_Accumulate(
a: &RawServoAnimationValue,
b: &RawServoAnimationValue,
count: u64,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let a_value = AnimationValue::as_arc(&a);
let b_value = AnimationValue::as_arc(&b);
if let Ok(value) = a_value.animate(b_value, Procedure::Accumulate { count }) {
@ -416,7 +415,7 @@ pub extern "C" fn Servo_AnimationValues_Accumulate(
#[no_mangle]
pub extern "C" fn Servo_AnimationValues_GetZeroValue(
value_to_match: &RawServoAnimationValue,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let value_to_match = AnimationValue::as_arc(&value_to_match);
if let Ok(zero_value) = value_to_match.to_animated_zero() {
Arc::new(zero_value).into_strong()
@ -598,7 +597,7 @@ pub extern "C" fn Servo_ComposeAnimationSegment(
iteration_composite: IterationCompositeOperation,
progress: f64,
current_iteration: u64,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let underlying_value = AnimationValue::arc_from_borrowed(&underlying_value).map(|v| &**v);
let last_value = AnimationValue::arc_from_borrowed(&last_value).map(|v| &**v);
let result = compose_animation_segment(
@ -756,7 +755,7 @@ pub extern "C" fn Servo_AnimationValue_GetOpacity(value: &RawServoAnimationValue
}
#[no_mangle]
pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> bindings::RawServoAnimationValueStrong {
pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> Strong<RawServoAnimationValue> {
Arc::new(AnimationValue::Opacity(opacity)).into_strong()
}
@ -764,7 +763,7 @@ pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> bindings::RawSer
pub extern "C" fn Servo_AnimationValue_Color(
color_property: nsCSSPropertyID,
color: structs::nscolor,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
use style::gecko::values::convert_nscolor_to_rgba;
use style::values::animated::color::RGBA as AnimatedRGBA;
@ -835,7 +834,7 @@ pub unsafe extern "C" fn Servo_AnimationValue_GetTransform(
pub unsafe extern "C" fn Servo_AnimationValue_Transform(
property: nsCSSPropertyID,
list: *const nsCSSValueSharedList,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
use style::values::computed::transform::{Rotate, Scale, Translate};
let list = (&*list).mHead.as_ref();
@ -884,7 +883,7 @@ pub extern "C" fn Servo_AnimationValue_DeepEqual(
#[no_mangle]
pub extern "C" fn Servo_AnimationValue_Uncompute(
value: &RawServoAnimationValue,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
let value = AnimationValue::as_arc(&value);
let global_style_data = &*GLOBAL_STYLE_DATA;
Arc::new(
@ -931,7 +930,7 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(
element: &RawGeckoElement,
computed_values: &ComputedValues,
snapshots: *const ServoElementSnapshotTable,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
debug_assert!(!snapshots.is_null());
let computed_values = unsafe { ArcBorrow::from_ref(computed_values) };
@ -973,10 +972,10 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
computed_values: &ComputedValues,
snapshots: *const ServoElementSnapshotTable,
animation_value: &RawServoAnimationValue,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
debug_assert!(!snapshots.is_null());
let rules = match computed_values.rules {
None => return ComputedStyleStrong::null(),
None => return Strong::null(),
Some(ref rules) => rules,
};
@ -998,7 +997,7 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
let element = GeckoElement(element);
if element.borrow_data().is_none() {
return ComputedStyleStrong::null();
return Strong::null();
}
let shared = create_shared_context(
@ -1021,7 +1020,7 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(
computed_values: &ComputedValues,
property_id: nsCSSPropertyID,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let property = match LonghandId::from_nscsspropertyid(property_id) {
Ok(longhand) => longhand,
Err(()) => return Strong::null(),
@ -1217,7 +1216,7 @@ pub extern "C" fn Servo_Element_HasPrimaryComputedValues(element: &RawGeckoEleme
#[no_mangle]
pub extern "C" fn Servo_Element_GetPrimaryComputedValues(
element: &RawGeckoElement,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let element = GeckoElement(element);
let data = element
.borrow_data()
@ -1241,7 +1240,7 @@ pub extern "C" fn Servo_Element_HasPseudoComputedValues(
pub extern "C" fn Servo_Element_GetPseudoComputedValues(
element: &RawGeckoElement,
index: usize,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let element = GeckoElement(element);
let data = element
.borrow_data()
@ -1308,7 +1307,7 @@ fn mode_to_origin(mode: SheetParsingMode) -> Origin {
#[no_mangle]
pub extern "C" fn Servo_StyleSheet_Empty(
mode: SheetParsingMode,
) -> bindings::RawServoStyleSheetContentsStrong {
) -> Strong<RawServoStyleSheetContents> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let origin = mode_to_origin(mode);
let shared_lock = &global_style_data.shared_lock;
@ -1341,7 +1340,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
quirks_mode: nsCompatibility,
reusable_sheets: *mut LoaderReusableStyleSheets,
use_counters: Option<&UseCounters>,
) -> bindings::RawServoStyleSheetContentsStrong {
) -> Strong<RawServoStyleSheetContents> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let input: &str = unsafe { (*bytes).as_str_unchecked() };
@ -1684,7 +1683,7 @@ pub extern "C" fn Servo_StyleSheet_HasRules(
#[no_mangle]
pub extern "C" fn Servo_StyleSheet_GetRules(
sheet: &RawServoStyleSheetContents,
) -> bindings::ServoCssRulesStrong {
) -> Strong<ServoCssRules> {
StylesheetContents::as_arc(&sheet)
.rules
.clone()
@ -1695,7 +1694,7 @@ pub extern "C" fn Servo_StyleSheet_GetRules(
pub extern "C" fn Servo_StyleSheet_Clone(
raw_sheet: &RawServoStyleSheetContents,
reference_sheet: *const DomStyleSheet,
) -> bindings::RawServoStyleSheetContentsStrong {
) -> Strong<RawServoStyleSheetContents> {
use style::shared_lock::{DeepCloneParams, DeepCloneWithLock};
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
@ -1946,7 +1945,7 @@ macro_rules! impl_group_rule_funcs {
impl_basic_rule_funcs! { ($name, $rule_type, $raw_type), $($basic)+ }
#[no_mangle]
pub extern "C" fn $get_rules(rule: &$raw_type) -> bindings::ServoCssRulesStrong {
pub extern "C" fn $get_rules(rule: &$raw_type) -> Strong<ServoCssRules> {
read_locked_arc(rule, |rule: &$rule_type| {
rule.rules.clone().into_strong()
})
@ -2031,7 +2030,7 @@ impl_basic_rule_funcs! { (CounterStyle, CounterStyleRule, RawServoCounterStyleRu
#[no_mangle]
pub extern "C" fn Servo_StyleRule_GetStyle(
rule: &RawServoStyleRule,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
read_locked_arc(rule, |rule: &StyleRule| rule.block.clone().into_strong())
}
@ -2335,7 +2334,7 @@ pub extern "C" fn Servo_Keyframe_SetKeyText(
#[no_mangle]
pub extern "C" fn Servo_Keyframe_GetStyle(
keyframe: &RawServoKeyframe,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
read_locked_arc(keyframe, |keyframe: &Keyframe| {
keyframe.block.clone().into_strong()
})
@ -2378,7 +2377,7 @@ pub extern "C" fn Servo_KeyframesRule_GetKeyframeAt(
index: u32,
line: *mut u32,
column: *mut u32,
) -> bindings::RawServoKeyframeStrong {
) -> Strong<RawServoKeyframe> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let key = Locked::<KeyframesRule>::as_arc(&rule)
@ -2437,7 +2436,7 @@ pub extern "C" fn Servo_KeyframesRule_DeleteRule(rule: &RawServoKeyframesRule, i
#[no_mangle]
pub extern "C" fn Servo_MediaRule_GetMedia(
rule: &RawServoMediaRule,
) -> bindings::RawServoMediaListStrong {
) -> Strong<RawServoMediaList> {
read_locked_arc(rule, |rule: &MediaRule| {
rule.media_queries.clone().into_strong()
})
@ -2460,7 +2459,7 @@ pub extern "C" fn Servo_NamespaceRule_GetURI(rule: &RawServoNamespaceRule) -> *m
#[no_mangle]
pub extern "C" fn Servo_PageRule_GetStyle(
rule: &RawServoPageRule,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
read_locked_arc(rule, |rule: &PageRule| rule.block.clone().into_strong())
}
@ -2522,7 +2521,7 @@ pub extern "C" fn Servo_FontFeatureValuesRule_GetValueText(
}
#[no_mangle]
pub extern "C" fn Servo_FontFaceRule_CreateEmpty() -> bindings::RawServoFontFaceRuleStrong {
pub extern "C" fn Servo_FontFaceRule_CreateEmpty() -> Strong<RawServoFontFaceRule> {
let global_style_data = &*GLOBAL_STYLE_DATA;
// XXX This is not great. We should split FontFace descriptor data
// from the rule, so that we don't need to create the rule like this
@ -2539,7 +2538,7 @@ pub extern "C" fn Servo_FontFaceRule_CreateEmpty() -> bindings::RawServoFontFace
#[no_mangle]
pub unsafe extern "C" fn Servo_FontFaceRule_Clone(
rule: &RawServoFontFaceRule,
) -> bindings::RawServoFontFaceRuleStrong {
) -> Strong<RawServoFontFaceRule> {
let clone = read_locked_arc(rule, |rule: &FontFaceRule| rule.clone());
let global_style_data = &*GLOBAL_STYLE_DATA;
Arc::new(global_style_data.shared_lock.wrap(clone)).into_strong()
@ -3106,7 +3105,7 @@ pub unsafe extern "C" fn Servo_ComputedValues_GetForAnonymousBox(
parent_style_or_null: Option<&ComputedValues>,
pseudo: PseudoStyleType,
raw_data: &RawServoStyleSet,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let guards = StylesheetGuards::same(&guard);
@ -3162,7 +3161,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(
is_probe: bool,
inherited_style: Option<&ComputedValues>,
raw_data: &RawServoStyleSet,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let element = GeckoElement(element);
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
@ -3241,7 +3240,7 @@ pub extern "C" fn Servo_ComputedValues_ResolveXULTreePseudoStyle(
inherited_style: &ComputedValues,
input_word: *const AtomArray,
raw_data: &RawServoStyleSet,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let element = GeckoElement(element);
let data = element
.borrow_data()
@ -3435,7 +3434,7 @@ pub unsafe extern "C" fn Servo_ComputedValues_Inherit(
pseudo: PseudoStyleType,
parent_style_context: Option<&ComputedValues>,
target: structs::InheritTarget,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let for_text = target == structs::InheritTarget::Text;
@ -3558,7 +3557,7 @@ pub extern "C" fn Servo_ParseProperty(
parsing_mode: structs::ParsingMode,
quirks_mode: nsCompatibility,
loader: *mut Loader,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
let id =
get_property_id_from_nscsspropertyid!(property, Strong::null());
let mut declarations = SourcePropertyDeclaration::new();
@ -3714,7 +3713,7 @@ pub unsafe extern "C" fn Servo_ParseStyleAttribute(
raw_extra_data: *mut URLExtraData,
quirks_mode: nsCompatibility,
loader: *mut Loader,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let value = (*data).as_str_unchecked();
let reporter = ErrorReporter::new(ptr::null_mut(), loader, raw_extra_data);
@ -3729,7 +3728,7 @@ pub unsafe extern "C" fn Servo_ParseStyleAttribute(
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> bindings::RawServoDeclarationBlockStrong {
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> Strong<RawServoDeclarationBlock> {
let global_style_data = &*GLOBAL_STYLE_DATA;
Arc::new(
global_style_data
@ -3742,7 +3741,7 @@ pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> bindings::RawServoDecl
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_Clone(
declarations: &RawServoDeclarationBlock,
) -> bindings::RawServoDeclarationBlockStrong {
) -> Strong<RawServoDeclarationBlock> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -4068,7 +4067,7 @@ pub extern "C" fn Servo_DeclarationBlock_RemovePropertyById(
}
#[no_mangle]
pub extern "C" fn Servo_MediaList_Create() -> bindings::RawServoMediaListStrong {
pub extern "C" fn Servo_MediaList_Create() -> Strong<RawServoMediaList> {
let global_style_data = &*GLOBAL_STYLE_DATA;
Arc::new(global_style_data.shared_lock.wrap(MediaList::empty())).into_strong()
}
@ -4076,7 +4075,7 @@ pub extern "C" fn Servo_MediaList_Create() -> bindings::RawServoMediaListStrong
#[no_mangle]
pub extern "C" fn Servo_MediaList_DeepClone(
list: &RawServoMediaList,
) -> bindings::RawServoMediaListStrong {
) -> Strong<RawServoMediaList> {
let global_style_data = &*GLOBAL_STYLE_DATA;
read_locked_arc(list, |list: &MediaList| {
Arc::new(global_style_data.shared_lock.wrap(list.clone())).into_strong()
@ -4826,7 +4825,7 @@ pub extern "C" fn Servo_TakeChangeHint(
pub extern "C" fn Servo_ResolveStyle(
element: &RawGeckoElement,
_raw_data: &RawServoStyleSet,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let element = GeckoElement(element);
debug!("Servo_ResolveStyle: {:?}", element);
let data = element
@ -4849,7 +4848,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(
rule_inclusion: StyleRuleInclusion,
snapshots: *const ServoElementSnapshotTable,
raw_data: &RawServoStyleSet,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
debug_assert!(!snapshots.is_null());
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
@ -4927,7 +4926,7 @@ pub extern "C" fn Servo_ReparentStyle(
layout_parent_style: &ComputedValues,
element: Option<&RawGeckoElement>,
raw_data: &RawServoStyleSet,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
@ -5201,7 +5200,7 @@ pub extern "C" fn Servo_AnimationValue_Compute(
declarations: &RawServoDeclarationBlock,
style: &ComputedValues,
raw_data: &RawServoStyleSet,
) -> bindings::RawServoAnimationValueStrong {
) -> Strong<RawServoAnimationValue> {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let metrics = get_metrics_provider_for_product();
@ -5584,7 +5583,7 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
raw_data: &RawServoStyleSet,
parent_style_context: Option<&ComputedValues>,
declarations: &RawServoDeclarationBlock,
) -> ComputedStyleStrong {
) -> Strong<ComputedValues> {
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
@ -6288,7 +6287,7 @@ pub unsafe extern "C" fn Servo_IsCssPropertyRecordedInUseCounter(
}
#[no_mangle]
pub extern "C" fn Servo_Quotes_GetInitialValue() -> bindings::RawServoQuotesStrong {
pub extern "C" fn Servo_Quotes_GetInitialValue() -> Strong<RawServoQuotes> {
computed::Quotes::get_initial_value()
.0
.clone()