Bug 1538694 - Cleanup refcounted types. r=boris
☠☠ backed out by 105411e3cf06 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 26 Mar 2019 13:26:33 +0000
changeset 466110 f1eec8f7a3f87f9d8edbe3a2c5d6fa9c629eb6f2
parent 466109 76e7655d974e628646aa26b7d25fe7ef3a4ec615
child 466111 7bd834c5800c93f54df331311d726dc571813d7b
push id112561
push userdvarga@mozilla.com
push dateTue, 26 Mar 2019 22:00:04 +0000
treeherdermozilla-inbound@ba4174dac8c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1538694
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
layout/style/ComputedStyle.h
layout/style/DeclarationBlock.h
layout/style/GeckoBindings.cpp
layout/style/GeckoBindings.h
layout/style/ServoArcTypeList.h
layout/style/ServoBindingTypes.h
layout/style/ServoBindings.h
layout/style/ServoBindings.toml
servo/components/style/build_gecko.rs
servo/components/style/cbindgen.toml
servo/components/style/gecko/arc_types.rs
servo/components/style/gecko_bindings/sugar/ownership.rs
servo/ports/geckolib/glue.rs
--- a/layout/style/ComputedStyle.h
+++ b/layout/style/ComputedStyle.h
@@ -29,18 +29,16 @@ class nsIPresShell;
 class nsPresContext;
 class nsWindowSizes;
 
 #define STYLE_STRUCT(name_) struct nsStyle##name_;
 #include "nsStyleStructList.h"
 #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*);
 }
 
 namespace mozilla {
 
 namespace dom {
 class Document;
 }
@@ -86,19 +84,16 @@ class ComputedStyle {
   using Bit = ComputedStyleBit;
 
  public:
   ComputedStyle(PseudoStyleType aPseudoType,
                 ServoComputedDataForgotten aComputedValues);
 
   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().
   //
   // GetPseudo() and GetPseudoType() on this ComputedStyle return the
   // same as on |this|, and its depth in the tree (number of GetParent()
   // calls until null is returned) is the same as |this|, since its
   // parent is either |this|'s parent or |this|'s parent's
--- a/layout/style/DeclarationBlock.h
+++ b/layout/style/DeclarationBlock.h
@@ -143,25 +143,26 @@ class DeclarationBlock final {
   RawServoDeclarationBlock* Raw() const { return mRaw; }
   RawServoDeclarationBlock* const* RefRaw() const {
     static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
                       sizeof(RawServoDeclarationBlock*),
                   "RefPtr should just be a pointer");
     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 {
     Servo_DeclarationBlock_GetCssText(mRaw, &aResult);
   }
 
   uint32_t Count() const { return Servo_DeclarationBlock_Count(mRaw); }
 
--- a/layout/style/GeckoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -80,26 +80,16 @@
 #if defined(MOZ_MEMORY)
 #  include "mozmemory.h"
 #endif
 
 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;
 
 static RWLock* sServoFFILock = nullptr;
 
 static const nsFont* ThreadSafeGetDefaultFontHelper(const Document& aDocument,
                                                     nsAtom* aLanguage,
@@ -350,72 +340,72 @@ bool Gecko_HaveSeenPtr(SeenPtrs* aTable,
   MOZ_ASSERT(aTable);
   // Empty Rust allocations are indicated by small values up to the alignment
   // of the relevant type. We shouldn't see anything like that here.
   MOZ_ASSERT(uintptr_t(aPtr) > 16);
 
   return aTable->HaveSeenPtr(aPtr);
 }
 
-const RawServoDeclarationBlockStrong* Gecko_GetStyleAttrDeclarationBlock(
+const StyleStrong<RawServoDeclarationBlock>* Gecko_GetStyleAttrDeclarationBlock(
     const Element* aElement) {
   DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
   if (!decl) {
     return nullptr;
   }
   return decl->RefRawStrong();
 }
 
 void Gecko_UnsetDirtyStyleAttr(const Element* aElement) {
   DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
   if (!decl) {
     return;
   }
   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) {
     auto* svg = SVGElement::FromNodeOrNull(aElement);
     if (svg) {
       if (auto decl = svg->GetContentDeclarationBlock()) {
         return decl->RefRawStrong();
       }
     }
     return nullptr;
   }
 
   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;
   }
   const HTMLTableCellElement* cell =
       static_cast<const HTMLTableCellElement*>(aElement);
   if (nsMappedAttributes* attrs =
           cell->GetMappedAttributesInheritedFromTable()) {
     return AsRefRawStrong(attrs->GetServoStyle());
   }
   return nullptr;
 }
 
-const RawServoDeclarationBlockStrong*
+const StyleStrong<RawServoDeclarationBlock>*
 Gecko_GetUnvisitedLinkAttrDeclarationBlock(const Element* aElement) {
   nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
   if (!sheet) {
     return nullptr;
   }
 
   return AsRefRawStrong(sheet->GetServoUnvisitedLinkDecl());
 }
@@ -443,28 +433,28 @@ void Gecko_StyleSheet_AddRef(const Style
   const_cast<StyleSheet*>(aSheet)->AddRef();
 }
 
 void Gecko_StyleSheet_Release(const StyleSheet* aSheet) {
   MOZ_ASSERT(NS_IsMainThread());
   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;
   }
 
   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;
   }
 
   return AsRefRawStrong(sheet->GetServoActiveLinkDecl());
 }
 
@@ -1636,17 +1626,17 @@ void Gecko_nsStyleSVG_SetContextProperti
 }
 
 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* aDst,
                                             const nsStyleSVG* aSrc) {
   aDst->mContextProps = aSrc->mContextProps;
   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();
 }
 
 MOZ_DEFINE_MALLOC_SIZE_OF(GeckoURLValueMallocSizeOf)
 
 size_t Gecko_URLValue_SizeOfIncludingThis(URLValue* aURL) {
@@ -2055,17 +2045,18 @@ GeckoFontMetrics Gecko_GetFontMetrics(co
                     ? NS_round(aPresContext->AppUnitsPerDevPixel() * zeroWidth)
                     : -1.0;
   return ret;
 }
 
 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;
   RefPtr<RawServoStyleSheetContents> sheetContents = aSheetContents.Consume();
   NS_DispatchToMainThread(NS_NewRunnableFunction(
       __func__, [d = std::move(loadData), contents = std::move(sheetContents),
                  counters = std::move(useCounters)]() mutable {
         MOZ_ASSERT(NS_IsMainThread());
@@ -2123,32 +2114,32 @@ static already_AddRefed<StyleSheet> Load
 
   RefPtr<StyleSheet> sheet = static_cast<StyleSheet*>(aParent->GetFirstChild());
   return sheet.forget();
 }
 
 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.
   // (CORS_NONE is used for all imported sheets in Load::LoadChildSheet.)
   RefPtr<URLValue> url = new URLValue(aCssUrl.Consume(), CORS_NONE);
   return LoadImportSheet(aLoader, aParent, aParentLoadData, aReusableSheets,
                          url, aMediaList.Consume())
       .take();
 }
 
 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.)
   RefPtr<URLValue> urlVal = new URLValue(aCssUrl.Consume(), CORS_NONE);
   RefPtr<RawServoMediaList> mediaList = aMediaList.Consume();
   RefPtr<RawServoImportRule> importRule = aImportRule.Consume();
   NS_DispatchToMainThread(NS_NewRunnableFunction(
       __func__,
--- a/layout/style/GeckoBindings.h
+++ b/layout/style/GeckoBindings.h
@@ -104,29 +104,30 @@ void Gecko_DestroyStyleChildrenIterator(
 
 const nsINode* Gecko_GetNextStyleChild(mozilla::dom::StyleChildrenIterator*);
 
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
                                    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*);
 bool Gecko_IsRootElement(const mozilla::dom::Element*);
 
 bool Gecko_MatchLang(const mozilla::dom::Element*, nsAtom* override_lang,
                      bool has_override_lang, const char16_t* value);
 
@@ -165,37 +166,37 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNC
                                               const mozilla::dom::Element*)
 
 SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
     Gecko_Snapshot, const mozilla::ServoElementSnapshot*)
 
 #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.
 
 // Returns whether visited styles are enabled for a given document.
 bool Gecko_VisitedStylesEnabled(const mozilla::dom::Document*);
 
 // Animations
 bool Gecko_GetAnimationRule(
@@ -562,18 +563,18 @@ void Gecko_nsStyleSVG_SetDashArrayLength
 
 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
 
 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);
 
 void Gecko_GetComputedURLSpec(const mozilla::css::URLValue* url,
                               nsCString* spec);
 
 void Gecko_GetComputedImageURLSpec(const mozilla::css::URLValue* url,
                                    nsCString* spec);
--- a/layout/style/ServoArcTypeList.h
+++ b/layout/style/ServoArcTypeList.h
@@ -32,14 +32,14 @@ SERVO_ARC_TYPE(Keyframe, RawServoKeyfram
 SERVO_ARC_TYPE(KeyframesRule, RawServoKeyframesRule)
 SERVO_ARC_TYPE(MediaList, RawServoMediaList)
 SERVO_ARC_TYPE(MediaRule, RawServoMediaRule)
 SERVO_ARC_TYPE(NamespaceRule, RawServoNamespaceRule)
 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
--- a/layout/style/ServoBindingTypes.h
+++ b/layout/style/ServoBindingTypes.h
@@ -139,32 +139,29 @@ namespace dom {
 class StyleChildrenIterator;
 class Document;
 class Element;
 }  // namespace dom
 
 }  // 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_*);                           \
   }                                                                     \
   namespace mozilla {                                                   \
   template <>                                                           \
   struct RefPtrTraits<type_> {                                          \
     static void AddRef(type_* aPtr) { Servo_##name_##_AddRef(aPtr); }   \
     static void Release(type_* aPtr) { Servo_##name_##_Release(aPtr); } \
   };                                                                    \
   }
 #include "mozilla/ServoArcTypeList.h"
+SERVO_ARC_TYPE(ComputedStyle, mozilla::ComputedStyle)
 #undef SERVO_ARC_TYPE
 
 #define SERVO_BOXED_TYPE(name_, type_)                              \
   struct type_;                                                     \
   extern "C" void Servo_##name_##_Drop(mozilla::StyleOwned<type_>); \
   namespace mozilla {                                               \
   template <>                                                       \
   class DefaultDelete<type_> {                                      \
@@ -182,16 +179,9 @@ SERVO_BOXED_TYPE(UseCounters, StyleUseCo
 #undef SERVO_BOXED_TYPE
 
 // Other special cases.
 
 // TODO(heycam): Handle these elsewhere.
 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
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -57,62 +57,63 @@ void Servo_Element_ClearData(const mozil
 
 size_t Servo_Element_SizeOfExcludingThisAndCVs(
     mozilla::MallocSizeOf malloc_size_of,
     mozilla::MallocSizeOf malloc_enclosing_size_of,
     mozilla::SeenPtrs* seen_ptrs, const mozilla::dom::Element* node);
 
 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);
 
 bool Servo_Element_IsPrimaryStyleReusedViaRuleNode(
     const mozilla::dom::Element* element);
 
 void Servo_InvalidateStyleForDocStateChanges(
     const mozilla::dom::Element* root, const RawServoStyleSet* doc_styles,
     const nsTArray<const RawServoAuthorStyles*>* non_document_styles,
     uint64_t aStatesChanged);
 
 // 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,
     mozilla::URLExtraData* extra_data, uint32_t line_number_offset,
     nsCompatibility quirks_mode,
     mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
     const StyleUseCounters* use_counters);
 
 void Servo_StyleSheet_FromUTF8BytesAsync(
     mozilla::css::SheetLoadDataHolder* load_data,
     mozilla::URLExtraData* extra_data, const nsACString* bytes,
     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);
 
 size_t Servo_StyleSheet_SizeOfIncludingThis(
     mozilla::MallocSizeOf malloc_size_of,
     mozilla::MallocSizeOf malloc_enclosing_size_of,
     const RawServoStyleSheetContents* sheet);
 
@@ -172,17 +173,18 @@ void Servo_StyleSet_GetFontFaceRules(con
 const RawServoCounterStyleRule* Servo_StyleSet_GetCounterStyleRule(
     const RawServoStyleSet* set, nsAtom* name);
 
 // This function may return nullptr or gfxFontFeatureValueSet with zero
 // references.
 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);
 
 mozilla::StyleOwnedOrNull<RawServoSelectorList> Servo_SelectorList_Parse(
     const nsACString* selector_list);
 mozilla::StyleOwned<RawServoSourceSizeList> Servo_SourceSizeList_Parse(
     const nsACString* value);
 
@@ -232,20 +234,16 @@ void Servo_AuthorStyles_ForceDirty(RawSe
 void Servo_AuthorStyles_Flush(RawServoAuthorStyles*,
                               const RawServoStyleSet* document_styles);
 
 size_t Servo_AuthorStyles_SizeOfIncludingThis(
     mozilla::MallocSizeOf malloc_size_of,
     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);
 
 bool Servo_StyleSet_HasStateDependency(const RawServoStyleSet* set,
                                        const mozilla::dom::Element* element,
                                        uint64_t state);
 
@@ -267,25 +265,26 @@ nsresult Servo_CssRules_InsertRule(const
 nsresult Servo_CssRules_DeleteRule(const ServoCssRules* rules, uint32_t index);
 
 // CSS Rules
 
 #define BASIC_RULE_FUNCS_WITHOUT_GETTER(type_)                            \
   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)
 BASIC_RULE_FUNCS(Import)
 BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)
 BASIC_RULE_FUNCS(Keyframes)
 GROUP_RULE_FUNCS(Media)
 GROUP_RULE_FUNCS(MozDocument)
@@ -297,17 +296,17 @@ BASIC_RULE_FUNCS(FontFace)
 BASIC_RULE_FUNCS(CounterStyle)
 
 #undef GROUP_RULE_FUNCS
 #undef BASIC_RULE_FUNCS
 #undef BASIC_RULE_FUNCS_WITHOUT_GETTER
 
 using Matrix4x4Components = float[16];
 
-RawServoDeclarationBlockStrong Servo_StyleRule_GetStyle(
+mozilla::StyleStrong<RawServoDeclarationBlock> Servo_StyleRule_GetStyle(
     const RawServoStyleRule*);
 
 void Servo_StyleRule_SetStyle(const RawServoStyleRule* rule,
                               const RawServoDeclarationBlock* declarations);
 
 void Servo_StyleRule_GetSelectorText(const RawServoStyleRule* rule,
                                      nsAString* result);
 
@@ -340,52 +339,53 @@ void Servo_ImportRule_SetSheet(const Raw
 
 void Servo_Keyframe_GetKeyText(const RawServoKeyframe* keyframe,
                                nsAString* result);
 
 // Returns whether it successfully changes the key text.
 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,
                              const RawServoDeclarationBlock* declarations);
 
 nsAtom* Servo_KeyframesRule_GetName(const RawServoKeyframesRule* rule);
 
 // This method takes an addrefed nsAtom.
 void Servo_KeyframesRule_SetName(const RawServoKeyframesRule* rule,
                                  nsAtom* name);
 
 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);
 
 // Returns the index of the rule, max value of uint32_t if nothing found.
 uint32_t Servo_KeyframesRule_FindRule(const RawServoKeyframesRule* rule,
                                       const nsACString* key);
 
 // Returns whether it successfully appends the rule.
 bool Servo_KeyframesRule_AppendRule(const RawServoKeyframesRule* rule,
                                     const RawServoStyleSheetContents* sheet,
                                     const nsACString* css);
 
 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,
                              const RawServoDeclarationBlock* declarations);
 
 void Servo_SupportsRule_GetConditionText(const RawServoSupportsRule* rule,
                                          nsAString* result);
 
@@ -393,19 +393,19 @@ void Servo_MozDocumentRule_GetConditionT
                                             nsAString* result);
 
 void Servo_FontFeatureValuesRule_GetFontFamily(
     const RawServoFontFeatureValuesRule* rule, nsAString* result);
 
 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,
                                           uint32_t* line, uint32_t* column);
 
 uint32_t Servo_FontFaceRule_Length(const RawServoFontFaceRule* rule);
 
 nsCSSFontDesc Servo_FontFaceRule_IndexGetter(const RawServoFontFaceRule* rule,
@@ -488,17 +488,17 @@ void Servo_CounterStyleRule_GetDescripto
     nsAString* result);
 
 bool Servo_CounterStyleRule_SetDescriptor(const RawServoCounterStyleRule* rule,
                                           nsCSSCounterDesc desc,
                                           const nsACString* value);
 
 // 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);
 
 bool Servo_ParseEasing(const nsAString* easing, mozilla::URLExtraData* data,
                        nsTimingFunction* output);
 
 void Servo_SerializeEasing(const nsTimingFunction* easing, nsAString* output);
@@ -506,17 +506,18 @@ void Servo_SerializeEasing(const nsTimin
 void Servo_SerializeBorderRadius(const mozilla::StyleBorderRadius*, nsAString*);
 
 void Servo_GetComputedKeyframeValues(
     const nsTArray<mozilla::Keyframe>* keyframes,
     const mozilla::dom::Element* element, const mozilla::ComputedStyle* style,
     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(
     const mozilla::ComputedStyle* computed_values);
 
 bool Servo_Property_IsAnimatable(nsCSSPropertyID property);
 bool Servo_Property_IsTransitionable(nsCSSPropertyID property);
 bool Servo_Property_IsDiscreteAnimatable(nsCSSPropertyID property);
@@ -533,74 +534,76 @@ void Servo_MatrixTransform_Operate(
 void Servo_GetAnimationValues(
     const RawServoDeclarationBlock* declarations,
     const mozilla::dom::Element* element, const mozilla::ComputedStyle* style,
     const RawServoStyleSet* style_set,
     nsTArray<RefPtr<RawServoAnimationValue>>* animation_values);
 
 // 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,
                                              const RawServoAnimationValue* to);
 
 void Servo_AnimationValue_Serialize(const RawServoAnimationValue* value,
                                     nsCSSPropertyID property,
                                     nsAString* buffer);
 
 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,
                                    const RawServoDeclarationBlock* b);
 
 void Servo_DeclarationBlock_GetCssText(
     const RawServoDeclarationBlock* declarations, nsAString* result);
 
@@ -668,17 +671,17 @@ void Servo_AnimationCompose(
 
 // Calculate the result of interpolating given animation segment at the given
 // progress and current iteration.
 // This includes combining the segment endpoints with the underlying value
 // and/or last value depending the composite modes specified on the
 // 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,
     mozilla::dom::IterationCompositeOperation iter_composite, double progress,
     uint64_t current_iteration);
 
 // presentation attributes
 
@@ -739,19 +742,19 @@ void Servo_DeclarationBlock_SetTextDecor
     const RawServoDeclarationBlock* declarations);
 
 void Servo_DeclarationBlock_SetBackgroundImage(
     const RawServoDeclarationBlock* declarations, const nsAString& value,
     mozilla::URLExtraData* extra_data);
 
 // 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,
                              const RawServoStyleSet* set);
 
 void Servo_MediaList_GetText(const RawServoMediaList* list, nsAString* result);
 
 void Servo_MediaList_SetText(const RawServoMediaList* list,
@@ -776,21 +779,22 @@ size_t Servo_MediaList_SizeOfIncludingTh
 
 // CSS supports();
 
 bool Servo_CSSSupports2(const nsACString* name, const nsACString* value);
 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);
 
 // Gets the source style rules for the computed values. This returns
 // the result via rules, which would include a list of unowned pointers
 // to RawServoStyleRule.
 void Servo_ComputedValues_GetStyleRuleList(
     const mozilla::ComputedStyle* values,
@@ -810,25 +814,26 @@ void Servo_NoteExplicitHints(const mozil
                              nsChangeHint);
 
 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
 // work as return values with the Linux 32-bit ABI at the moment because
 // they wrap the value in a struct.
 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);
 
 void Servo_SetExplicitStyle(const mozilla::dom::Element* element,
                             const mozilla::ComputedStyle* primary_style);
 
 bool Servo_HasAuthorSpecifiedRules(const RawServoStyleSet* set,
@@ -840,24 +845,24 @@ bool Servo_HasAuthorSpecifiedRules(const
 // restyles first. The Element and its ancestors may be unstyled, have pending
 // restyles, or be in a display:none subtree. Styles are cached when possible,
 // though caching is not possible within display:none subtrees, and the styles
 // may be invalidated by already-scheduled restyles.
 //
 // 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,
     const mozilla::ComputedStyle* layout_parent_style,
     // element is null if there is no content node involved, or if it's not an
     // element.
     const mozilla::dom::Element* element, const RawServoStyleSet* set);
 
@@ -874,23 +879,25 @@ void Servo_AssertTreeIsClean(const mozil
 // Returns true if the current thread is a Servo parallel worker thread.
 bool Servo_IsWorkerThread();
 
 // Checks whether the rule tree has crossed its threshold for unused rule nodes,
 // and if so, frees them.
 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,
     const RawServoAnimationValue* animation);
 
 // For canvas font.
 void Servo_SerializeFontValueForCanvas(
     const RawServoDeclarationBlock* declarations, nsAString* buffer);
@@ -973,25 +980,18 @@ mozilla::StyleOwned<StyleUseCounters> Se
 
 void Servo_UseCounters_Merge(const StyleUseCounters* doc_counters,
                              const StyleUseCounters* sheet_counters);
 
 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"
 
 #endif  // mozilla_ServoBindings_h
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -451,16 +451,17 @@ cbindgen-types = [
     { gecko = "StyleContain", servo = "values::computed::Contain" },
     { gecko = "StyleRestyleHint", servo = "invalidation::element::restyle_hints::RestyleHint" },
     { gecko = "StyleTouchAction", servo = "values::computed::TouchAction" },
     { gecko = "StyleWillChangeBits", servo = "values::specified::box_::WillChangeBits" },
     { gecko = "StyleTextDecorationLine", servo = "values::computed::TextDecorationLine" },
     { 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 = [
     { generic = true, gecko = "mozilla::RustCell", servo = "::std::cell::Cell" },
     { generic = false, gecko = "ServoNodeData", servo = "AtomicRefCell<ElementData>" },
     { generic = false, gecko = "mozilla::ServoWritingMode", servo = "::logical_geometry::WritingMode" },
     { generic = false, gecko = "mozilla::ServoCustomPropertiesMap", servo = "Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>" },
     { generic = false, gecko = "mozilla::ServoRuleNode", servo = "Option<::rule_tree::StrongRuleNode>" },
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -215,54 +215,16 @@ mod bindings {
         }
         let bytes = result.into_bytes();
         File::create(&out_file)
             .unwrap()
             .write_all(&bytes)
             .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,
         used_keys: HashSet<&'static str>,
     }
     impl<'a> BuilderWithConfig<'a> {
         fn new(builder: Builder, config: &'a Table) -> Self {
             BuilderWithConfig {
@@ -429,28 +391,20 @@ mod bindings {
 
     // FIXME(emilio): Avoid this altogether.
     fn generate_bindings() {
         let builder = Builder::get_initial_builder()
             .disable_name_namespacing()
             .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);
     }
 
     fn generate_atoms() {
         let script = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap())
             .join("gecko")
             .join("regen_atoms.py");
         println!("cargo:rerun-if-changed={}", script.display());
--- a/servo/components/style/cbindgen.toml
+++ b/servo/components/style/cbindgen.toml
@@ -106,16 +106,17 @@ include = [
   "Contain",
   "RestyleHint",
   "TouchAction",
   "WillChangeBits",
   "TextDecorationLine",
   "MozListReversed",
   "Owned",
   "OwnedOrNull",
+  "Strong",
 ]
 item_types = ["enums", "structs", "typedefs"]
 
 [export.body]
 "CSSPixelLength" = """
   inline nscoord ToAppUnits() const;
   inline bool IsZero() const;
 """
@@ -223,8 +224,16 @@ item_types = ["enums", "structs", "typed
 
 "OwnedOrNull" = """
   UniquePtr<GeckoType> Consume() {
     UniquePtr<GeckoType> ret(ptr);
     ptr = nullptr;
     return ret;
   }
 """
+
+"Strong" = """
+  already_AddRefed<GeckoType> Consume() {
+    already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
+    ptr = nullptr;
+    return ret;
+  }
+"""
--- a/servo/components/style/gecko/arc_types.rs
+++ b/servo/components/style/gecko/arc_types.rs
@@ -13,33 +13,30 @@ use crate::gecko_bindings::structs::RawS
 use crate::gecko_bindings::structs::RawServoFontFeatureValuesRule;
 use crate::gecko_bindings::structs::RawServoImportRule;
 use crate::gecko_bindings::structs::RawServoKeyframe;
 use crate::gecko_bindings::structs::RawServoKeyframesRule;
 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;
 use crate::gecko_bindings::structs::RawServoCssUrlData;
 use crate::gecko_bindings::structs::RawServoDeclarationBlock;
 use crate::gecko_bindings::structs::RawServoFontFaceRule;
 use crate::gecko_bindings::structs::RawServoMediaList;
 use crate::gecko_bindings::structs::RawServoQuotes;
 use crate::gecko_bindings::structs::RawServoStyleRule;
 use crate::gecko_bindings::structs::RawServoStyleSheetContents;
 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};
 use crate::stylesheets::{DocumentRule, ImportRule, KeyframesRule, MediaRule};
 use crate::stylesheets::{NamespaceRule, PageRule};
 use crate::stylesheets::{StyleRule, StylesheetContents, SupportsRule};
 use servo_arc::{Arc, ArcBorrow};
 use std::{mem, ptr};
@@ -116,41 +113,16 @@ impl_arc_ffi!(Locked<CounterStyleRule> =
               [Servo_CounterStyleRule_AddRef, Servo_CounterStyleRule_Release]);
 
 impl_arc_ffi!(CssUrlData => RawServoCssUrlData
               [Servo_CssUrlData_AddRef, Servo_CssUrlData_Release]);
 
 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
 // an &ComputedStyle, which in general is not allowed. So we
 // implement the restricted set of arc type functionality we need.
 
 #[no_mangle]
 pub unsafe extern "C" fn Servo_ComputedStyle_AddRef(obj: &ComputedValues) {
--- a/servo/components/style/gecko_bindings/sugar/ownership.rs
+++ b/servo/components/style/gecko_bindings/sugar/ownership.rs
@@ -130,22 +130,22 @@ pub unsafe trait HasArcFFI: HasFFI {
                 Some(transmute::<&&Self::FFIType, &RawOffsetArc<_>>(reference))
             } else {
                 None
             }
         }
     }
 }
 
-#[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>,
 }
 
 impl<GeckoType> Strong<GeckoType> {
     #[inline]
     /// Returns whether this reference is null.
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -68,17 +68,16 @@ use style::gecko_bindings::structs::nsCo
 use style::gecko_bindings::structs::nsStyleTransformMatrix::MatrixTransformOperator;
 use style::gecko_bindings::structs::nsTArray;
 use style::gecko_bindings::structs::nsTimingFunction;
 use style::gecko_bindings::structs::nsresult;
 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;
 use style::gecko_bindings::structs::LoaderReusableStyleSheets;
 use style::gecko_bindings::structs::MallocSizeOf as GeckoMallocSizeOf;
 use style::gecko_bindings::structs::OriginFlags;
 use style::gecko_bindings::structs::PropertyValuePair;
 use style::gecko_bindings::structs::RawServoSelectorList;
@@ -357,17 +356,17 @@ pub extern "C" fn Servo_MaybeGCRuleTree(
     }
 }
 
 #[no_mangle]
 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 }) {
         Arc::new(value).into_strong()
     } else {
         Strong::null()
     }
 }
@@ -383,45 +382,45 @@ pub extern "C" fn Servo_AnimationValues_
         .animate(to_value, Procedure::Interpolate { progress: 0.5 })
         .is_ok()
 }
 
 #[no_mangle]
 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) {
         Arc::new(value).into_strong()
     } else {
         Strong::null()
     }
 }
 
 #[no_mangle]
 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 }) {
         Arc::new(value).into_strong()
     } else {
         Strong::null()
     }
 }
 
 #[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()
     } else {
         Strong::null()
     }
 }
 
@@ -593,17 +592,17 @@ fn compose_animation_segment(
 #[no_mangle]
 pub extern "C" fn Servo_ComposeAnimationSegment(
     segment: &structs::AnimationPropertySegment,
     underlying_value: Option<&RawServoAnimationValue>,
     last_value: Option<&RawServoAnimationValue>,
     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(
         segment,
         underlying_value,
         last_value,
         iteration_composite,
         current_iteration,
@@ -751,25 +750,25 @@ pub extern "C" fn Servo_AnimationValue_G
     if let AnimationValue::Opacity(opacity) = **value {
         opacity
     } else {
         panic!("The AnimationValue should be Opacity");
     }
 }
 
 #[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()
 }
 
 #[no_mangle]
 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;
 
     let property = LonghandId::from_nscsspropertyid(color_property)
         .expect("We don't have shorthand property animation value");
 
     let rgba = convert_nscolor_to_rgba(color);
 
@@ -830,17 +829,17 @@ pub unsafe extern "C" fn Servo_Animation
         _ => unreachable!("Unsupported transform-like animation value"),
     }
 }
 
 #[no_mangle]
 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();
 
     let property = LonghandId::from_nscsspropertyid(property)
         .expect("We don't have shorthand property animation value");
     let transform = gecko_properties::clone_transform_from_list(list);
     match property {
@@ -879,17 +878,17 @@ pub extern "C" fn Servo_AnimationValue_D
     let this_value = AnimationValue::as_arc(&this);
     let other_value = AnimationValue::as_arc(&other);
     this_value == other_value
 }
 
 #[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(
         global_style_data
             .shared_lock
             .wrap(PropertyDeclarationBlock::with_one(
                 value.uncompute(),
                 Importance::Normal,
@@ -926,17 +925,17 @@ fn resolve_rules_for_element_with_contex
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(
     raw_style_set: &RawServoStyleSet,
     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) };
 
     let rules = match computed_values.rules {
         None => return computed_values.clone_arc().into(),
         Some(ref rules) => rules,
     };
 
@@ -968,20 +967,20 @@ pub extern "C" fn Servo_StyleSet_GetBase
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
     raw_style_set: &RawServoStyleSet,
     element: &RawGeckoElement,
     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,
     };
 
     let global_style_data = &*GLOBAL_STYLE_DATA;
     let guard = global_style_data.shared_lock.read();
     let uncomputed_value = AnimationValue::as_arc(&animation_value).uncompute();
     let doc_data = PerDocumentStyleData::from_ffi(raw_style_set).borrow();
 
@@ -993,17 +992,17 @@ pub extern "C" fn Servo_StyleSet_GetComp
         doc_data
             .stylist
             .rule_tree()
             .add_animation_rules_at_transition_level(rules, declarations, &guards)
     };
 
     let element = GeckoElement(element);
     if element.borrow_data().is_none() {
-        return ComputedStyleStrong::null();
+        return Strong::null();
     }
 
     let shared = create_shared_context(
         &global_style_data,
         &guard,
         &doc_data,
         TraversalFlags::empty(),
         unsafe { &*snapshots },
@@ -1016,17 +1015,17 @@ pub extern "C" fn Servo_StyleSet_GetComp
 
     resolve_rules_for_element_with_context(element, context, with_animations_rules).into()
 }
 
 #[no_mangle]
 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(),
     };
     match AnimationValue::from_computed_values(property, &computed_values) {
         Some(v) => Arc::new(v).into_strong(),
         None => Strong::null(),
     }
@@ -1212,17 +1211,17 @@ pub extern "C" fn Servo_Element_HasPrima
         .borrow_data()
         .expect("Looking for CVs on unstyled element");
     data.has_styles()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_Element_GetPrimaryComputedValues(
     element: &RawGeckoElement,
-) -> ComputedStyleStrong {
+) -> Strong<ComputedValues> {
     let element = GeckoElement(element);
     let data = element
         .borrow_data()
         .expect("Getting CVs on unstyled element");
     data.styles.primary().clone().into()
 }
 
 #[no_mangle]
@@ -1236,17 +1235,17 @@ pub extern "C" fn Servo_Element_HasPseud
         .expect("Looking for CVs on unstyled element");
     data.styles.pseudos.as_array()[index].is_some()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_Element_GetPseudoComputedValues(
     element: &RawGeckoElement,
     index: usize,
-) -> ComputedStyleStrong {
+) -> Strong<ComputedValues> {
     let element = GeckoElement(element);
     let data = element
         .borrow_data()
         .expect("Getting CVs that aren't present");
     data.styles.pseudos.as_array()[index]
         .as_ref()
         .expect("Getting CVs that aren't present")
         .clone()
@@ -1303,17 +1302,17 @@ fn mode_to_origin(mode: SheetParsingMode
         SheetParsingMode::eUserSheetFeatures => Origin::User,
         SheetParsingMode::eAgentSheetFeatures => Origin::UserAgent,
     }
 }
 
 #[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;
     Arc::new(StylesheetContents::from_str(
         "",
         unsafe { dummy_url_data() }.clone(),
         origin,
         shared_lock,
@@ -1336,17 +1335,17 @@ pub extern "C" fn Servo_StyleSheet_FromU
     load_data: *mut SheetLoadData,
     bytes: *const nsACString,
     mode: SheetParsingMode,
     extra_data: *mut URLExtraData,
     line_number_offset: u32,
     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() };
 
     let reporter = ErrorReporter::new(stylesheet, loader, extra_data);
     let url_data = unsafe { UrlExtraData::from_ptr_ref(&extra_data) };
     let loader = if loader.is_null() {
         None
     } else {
@@ -1679,28 +1678,28 @@ pub extern "C" fn Servo_StyleSheet_HasRu
         .read_with(&guard)
         .0
         .is_empty()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSheet_GetRules(
     sheet: &RawServoStyleSheetContents,
-) -> bindings::ServoCssRulesStrong {
+) -> Strong<ServoCssRules> {
     StylesheetContents::as_arc(&sheet)
         .rules
         .clone()
         .into_strong()
 }
 
 #[no_mangle]
 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();
     let contents = StylesheetContents::as_arc(&raw_sheet);
     let params = DeepCloneParams { reference_sheet };
 
     Arc::new(contents.deep_clone_with_lock(&global_style_data.shared_lock, &guard, &params))
         .into_strong()
@@ -1941,17 +1940,17 @@ macro_rules! impl_basic_rule_funcs {
 macro_rules! impl_group_rule_funcs {
     { ($name:ident, $rule_type:ty, $raw_type:ty),
       get_rules: $get_rules:ident,
       $($basic:tt)+
     } => {
         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()
             })
         }
     }
 }
 
 impl_basic_rule_funcs! { (Style, StyleRule, RawServoStyleRule),
@@ -2026,17 +2025,17 @@ impl_basic_rule_funcs! { (CounterStyle, 
     getter: Servo_CssRules_GetCounterStyleRuleAt,
     debug: Servo_CounterStyleRule_Debug,
     to_css: Servo_CounterStyleRule_GetCssText,
 }
 
 #[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())
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleRule_SetStyle(
     rule: &RawServoStyleRule,
     declarations: &RawServoDeclarationBlock,
 ) {
@@ -2330,17 +2329,17 @@ pub extern "C" fn Servo_Keyframe_SetKeyT
     } else {
         false
     }
 }
 
 #[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()
     })
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_Keyframe_SetStyle(
     keyframe: &RawServoKeyframe,
@@ -2373,17 +2372,17 @@ pub extern "C" fn Servo_KeyframesRule_Ge
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_KeyframesRule_GetKeyframeAt(
     rule: &RawServoKeyframesRule,
     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)
         .read_with(&guard)
         .keyframes[index as usize]
         .clone();
     let location = key.read_with(&guard).source_location;
     *unsafe { line.as_mut().unwrap() } = location.line as u32;
@@ -2432,17 +2431,17 @@ pub extern "C" fn Servo_KeyframesRule_De
     write_locked_arc(rule, |rule: &mut KeyframesRule| {
         rule.keyframes.remove(index as usize);
     })
 }
 
 #[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()
     })
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_NamespaceRule_GetPrefix(
     rule: &RawServoNamespaceRule,
@@ -2455,17 +2454,17 @@ pub extern "C" fn Servo_NamespaceRule_Ge
 #[no_mangle]
 pub extern "C" fn Servo_NamespaceRule_GetURI(rule: &RawServoNamespaceRule) -> *mut nsAtom {
     read_locked_arc(rule, |rule: &NamespaceRule| rule.url.0.as_ptr())
 }
 
 #[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())
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_PageRule_SetStyle(
     rule: &RawServoPageRule,
     declarations: &RawServoDeclarationBlock,
 ) {
@@ -2517,34 +2516,34 @@ pub extern "C" fn Servo_FontFeatureValue
 ) {
     read_locked_arc(rule, |rule: &FontFeatureValuesRule| {
         rule.value_to_css(&mut CssWriter::new(unsafe { result.as_mut().unwrap() }))
             .unwrap();
     })
 }
 
 #[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
     // and the descriptor data itself can be hold in UniquePtr from the
     // Gecko side. See bug 1450904.
     Arc::new(
         global_style_data
             .shared_lock
             .wrap(FontFaceRule::empty(SourceLocation { line: 0, column: 0 })),
     )
     .into_strong()
 }
 
 #[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()
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn Servo_FontFaceRule_GetSourceLocation(
     rule: &RawServoFontFaceRule,
@@ -3101,17 +3100,17 @@ counter_style_descriptors! {
     ]
 }
 
 #[no_mangle]
 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);
     let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
     let pseudo = PseudoElement::from_pseudo_type(pseudo).unwrap();
     debug_assert!(pseudo.is_anon_box());
 
     let metrics = get_metrics_provider_for_product();
@@ -3157,17 +3156,17 @@ pub unsafe extern "C" fn Servo_ComputedV
 
 #[no_mangle]
 pub extern "C" fn Servo_ResolvePseudoStyle(
     element: &RawGeckoElement,
     pseudo_type: PseudoStyleType,
     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();
 
     debug!(
         "Servo_ResolvePseudoStyle: {:?} {:?}, is_probe: {}",
         element,
         PseudoElement::from_pseudo_type(pseudo_type),
         is_probe
@@ -3236,17 +3235,17 @@ fn debug_atom_array(atoms: &AtomArray) -
 
 #[no_mangle]
 pub extern "C" fn Servo_ComputedValues_ResolveXULTreePseudoStyle(
     element: &RawGeckoElement,
     pseudo_tag: *mut nsAtom,
     inherited_style: &ComputedValues,
     input_word: *const AtomArray,
     raw_data: &RawServoStyleSet,
-) -> ComputedStyleStrong {
+) -> Strong<ComputedValues> {
     let element = GeckoElement(element);
     let data = element
         .borrow_data()
         .expect("Calling ResolveXULTreePseudoStyle on unstyled element?");
 
     let pseudo = unsafe {
         Atom::with(pseudo_tag, |atom| {
             PseudoElement::from_tree_pseudo_atom(atom, Box::new([]))
@@ -3430,17 +3429,17 @@ fn get_pseudo_style(
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn Servo_ComputedValues_Inherit(
     raw_data: &RawServoStyleSet,
     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;
     let pseudo = PseudoElement::from_pseudo_type(pseudo).unwrap();
     debug_assert!(pseudo.is_anon_box());
 
     let mut style =
         StyleBuilder::for_inheritance(data.stylist.device(), parent_style_context, Some(&pseudo));
@@ -3553,17 +3552,17 @@ fn parse_property_into(
 #[no_mangle]
 pub extern "C" fn Servo_ParseProperty(
     property: nsCSSPropertyID,
     value: *const nsACString,
     data: *mut URLExtraData,
     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();
     let reporter = ErrorReporter::new(ptr::null_mut(), loader, data);
     let result = parse_property_into(
         &mut declarations,
         id,
         value,
@@ -3709,45 +3708,45 @@ pub extern "C" fn Servo_MatrixTransform_
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn Servo_ParseStyleAttribute(
     data: *const nsACString,
     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);
     let url_data = UrlExtraData::from_ptr_ref(&raw_extra_data);
     Arc::new(global_style_data.shared_lock.wrap(parse_style_attribute(
         value,
         url_data,
         reporter.as_ref().map(|r| r as &ParseErrorReporter),
         quirks_mode.into(),
     )))
     .into_strong()
 }
 
 #[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
             .shared_lock
             .wrap(PropertyDeclarationBlock::new()),
     )
     .into_strong()
 }
 
 #[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);
     Arc::new(
         global_style_data
             .shared_lock
             .wrap(declarations.read_with(&guard).clone()),
     )
@@ -4063,25 +4062,25 @@ pub extern "C" fn Servo_DeclarationBlock
     remove_property(
         declarations,
         get_property_id_from_nscsspropertyid!(property, false),
         before_change_closure,
     )
 }
 
 #[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()
 }
 
 #[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()
     })
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_MediaList_Matches(
@@ -4821,17 +4820,17 @@ pub extern "C" fn Servo_TakeChangeHint(
     // they wrap the value in a struct, so for now just unwrap it.
     damage.as_change_hint().0
 }
 
 #[no_mangle]
 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
         .borrow_data()
         .expect("Resolving style on unstyled element");
 
     debug_assert!(
         element.has_current_styles(&*data),
@@ -4844,17 +4843,17 @@ pub extern "C" fn Servo_ResolveStyle(
 
 #[no_mangle]
 pub extern "C" fn Servo_ResolveStyleLazily(
     element: &RawGeckoElement,
     pseudo_type: PseudoStyleType,
     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();
     let element = GeckoElement(element);
     let doc_data = PerDocumentStyleData::from_ffi(raw_data);
     let data = doc_data.borrow();
     let rule_inclusion = RuleInclusion::from(rule_inclusion);
     let pseudo = PseudoElement::from_pseudo_type(pseudo_type);
@@ -4922,17 +4921,17 @@ pub extern "C" fn Servo_ResolveStyleLazi
 #[no_mangle]
 pub extern "C" fn Servo_ReparentStyle(
     style_to_reparent: &ComputedValues,
     parent_style: &ComputedValues,
     parent_style_ignoring_first_line: &ComputedValues,
     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();
     let inputs = CascadeInputs::new_from_style(style_to_reparent);
     let metrics = get_metrics_provider_for_product();
     let pseudo = style_to_reparent.pseudo();
     let element = element.map(GeckoElement);
 
@@ -5196,17 +5195,17 @@ pub extern "C" fn Servo_GetAnimationValu
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_AnimationValue_Compute(
     element: &RawGeckoElement,
     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();
 
     let element = GeckoElement(element);
     let parent_element = element.inheritance_parent();
     let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
     let parent_style = parent_data
         .as_ref()
@@ -5579,17 +5578,17 @@ pub extern "C" fn Servo_StyleSet_BuildFo
     set
 }
 
 #[no_mangle]
 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();
     let guards = StylesheetGuards::same(&guard);
 
     let parent_style = match parent_style_context {
         Some(parent) => &*parent,
         None => doc_data.default_computed_values(),
@@ -6283,17 +6282,17 @@ pub unsafe extern "C" fn Servo_IsCssProp
         Some(id) => id,
         None => return false,
     };
 
     use_counters.non_custom_properties.recorded(non_custom_id)
 }
 
 #[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()
         .into_strong()
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_Quotes_Equal(a: &RawServoQuotes, b: &RawServoQuotes) -> bool {