From 708aff235ad0cb404476653aebab43ae4b59cc72 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 26 Sep 2016 22:03:25 +1000 Subject: [PATCH] Bug 1304302 part 5 - Make StyleSheet::As{Gecko,Servo} return pointer instead of reference. r=heycam To match the behavior of StyleSheetHandle so that we can simply replace uses of StyleSheetHandle with StyleSheet* in later patch. MozReview-Commit-ID: LfGKrUmzC4h --HG-- extra : source : bffc3be53b1c1142b3ab297a78fc6e7934719d2c --- layout/style/StyleSheet.cpp | 7 ++++--- layout/style/StyleSheet.h | 8 ++++---- layout/style/StyleSheetInlines.h | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 69524273c660..575e733fbe50 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -58,7 +58,8 @@ StyleSheet::IsComplete() const void StyleSheet::SetComplete() { - NS_ASSERTION(!IsGecko() || !AsGecko().mDirty, "Can't set a dirty sheet complete!"); + NS_ASSERTION(!IsGecko() || !AsGecko()->mDirty, + "Can't set a dirty sheet complete!"); SheetInfo().mComplete = true; if (mDocument && !mDisabled) { // Let the document know @@ -79,9 +80,9 @@ StyleSheetInfo& StyleSheet::SheetInfo() { if (IsServo()) { - return AsServo(); + return *AsServo(); } - return *AsGecko().mInner; + return *AsGecko()->mInner; } } // namespace mozilla diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index 78f13732d2c6..7ab953c3a2b7 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -67,11 +67,11 @@ public: // Only safe to call if the caller has verified that that |this| is of the // correct type. - inline CSSStyleSheet& AsGecko(); - inline ServoStyleSheet& AsServo(); + inline CSSStyleSheet* AsGecko(); + inline ServoStyleSheet* AsServo(); inline StyleSheetHandle AsHandle(); - inline const CSSStyleSheet& AsGecko() const; - inline const ServoStyleSheet& AsServo() const; + inline const CSSStyleSheet* AsGecko() const; + inline const ServoStyleSheet* AsServo() const; inline MozExternalRefCountType AddRef(); inline MozExternalRefCountType Release(); diff --git a/layout/style/StyleSheetInlines.h b/layout/style/StyleSheetInlines.h index 353fbaaab633..55b78aa6e0e7 100644 --- a/layout/style/StyleSheetInlines.h +++ b/layout/style/StyleSheetInlines.h @@ -13,41 +13,41 @@ namespace mozilla { -CSSStyleSheet& +CSSStyleSheet* StyleSheet::AsGecko() { MOZ_ASSERT(IsGecko()); - return *static_cast(this); + return static_cast(this); } -ServoStyleSheet& +ServoStyleSheet* StyleSheet::AsServo() { MOZ_ASSERT(IsServo()); - return *static_cast(this); + return static_cast(this); } StyleSheetHandle StyleSheet::AsHandle() { if (IsServo()) { - return &AsServo(); + return AsServo(); } - return &AsGecko(); + return AsGecko(); } -const CSSStyleSheet& +const CSSStyleSheet* StyleSheet::AsGecko() const { MOZ_ASSERT(IsGecko()); - return *static_cast(this); + return static_cast(this); } -const ServoStyleSheet& +const ServoStyleSheet* StyleSheet::AsServo() const { MOZ_ASSERT(IsServo()); - return *static_cast(this); + return static_cast(this); } #define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \ @@ -58,9 +58,9 @@ StyleSheet::AsServo() const decltype(&ServoStyleSheet::method_)>::value, \ "ServoStyleSheet should define its own " #method_); \ if (IsServo()) { \ - return AsServo().method_ servoargs_; \ + return AsServo()->method_ servoargs_; \ } \ - return AsGecko().method_ geckoargs_; + return AsGecko()->method_ geckoargs_; #define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_) @@ -140,7 +140,7 @@ StyleSheet::GetParentSheet() const void StyleSheet::AppendStyleSheet(StyleSheet* aSheet) { - FORWARD_CONCRETE(AppendStyleSheet, (&aSheet->AsGecko()), (&aSheet->AsServo())) + FORWARD_CONCRETE(AppendStyleSheet, (aSheet->AsGecko()), (aSheet->AsServo())) } nsIPrincipal*