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
This commit is contained in:
Xidorn Quan 2016-09-26 22:03:25 +10:00
parent 4d65721d59
commit 708aff235a
3 changed files with 21 additions and 20 deletions

View File

@ -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

View File

@ -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();

View File

@ -13,41 +13,41 @@
namespace mozilla {
CSSStyleSheet&
CSSStyleSheet*
StyleSheet::AsGecko()
{
MOZ_ASSERT(IsGecko());
return *static_cast<CSSStyleSheet*>(this);
return static_cast<CSSStyleSheet*>(this);
}
ServoStyleSheet&
ServoStyleSheet*
StyleSheet::AsServo()
{
MOZ_ASSERT(IsServo());
return *static_cast<ServoStyleSheet*>(this);
return static_cast<ServoStyleSheet*>(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<const CSSStyleSheet*>(this);
return static_cast<const CSSStyleSheet*>(this);
}
const ServoStyleSheet&
const ServoStyleSheet*
StyleSheet::AsServo() const
{
MOZ_ASSERT(IsServo());
return *static_cast<const ServoStyleSheet*>(this);
return static_cast<const ServoStyleSheet*>(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*