Bug 577002 Part 3: Make various ImportRule functions non-virtual and cleanup some return types. r=bzbarsky

This commit is contained in:
Craig Topper 2011-03-17 13:41:52 -04:00
parent 51c51ac5d7
commit c232171343
3 changed files with 14 additions and 36 deletions

View File

@ -75,13 +75,13 @@ public:
virtual PRInt32 GetType() const;
virtual already_AddRefed<nsICSSRule> Clone() const;
NS_IMETHOD SetURLSpec(const nsString& aURLSpec);
NS_IMETHOD GetURLSpec(nsString& aURLSpec) const;
void SetURLSpec(const nsString& aURLSpec) { mURLSpec = aURLSpec; }
void GetURLSpec(nsString& aURLSpec) const { aURLSpec = mURLSpec; }
NS_IMETHOD SetMedia(const nsString& aMedia);
NS_IMETHOD GetMedia(nsString& aMedia) const;
nsresult SetMedia(const nsString& aMedia);
void GetMedia(nsString& aMedia) const;
NS_IMETHOD SetSheet(nsCSSStyleSheet*);
void SetSheet(nsCSSStyleSheet*);
// nsIDOMCSSRule interface
NS_DECL_NSIDOMCSSRULE

View File

@ -429,21 +429,7 @@ ImportRule::Clone() const
return clone.forget();
}
NS_IMETHODIMP
ImportRule::SetURLSpec(const nsString& aURLSpec)
{
mURLSpec = aURLSpec;
return NS_OK;
}
NS_IMETHODIMP
ImportRule::GetURLSpec(nsString& aURLSpec) const
{
aURLSpec = mURLSpec;
return NS_OK;
}
NS_IMETHODIMP
nsresult
ImportRule::SetMedia(const nsString& aMedia)
{
if (mMedia) {
@ -453,34 +439,30 @@ ImportRule::SetMedia(const nsString& aMedia)
}
}
NS_IMETHODIMP
void
ImportRule::GetMedia(nsString& aMedia) const
{
if (mMedia) {
return mMedia->GetText(aMedia);
mMedia->GetText(aMedia);
} else {
aMedia.Truncate();
return NS_OK;
}
}
NS_IMETHODIMP
void
ImportRule::SetSheet(nsCSSStyleSheet* aSheet)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aSheet);
NS_PRECONDITION(aSheet, "null arg");
// set the new sheet
mChildSheet = aSheet;
aSheet->SetOwnerRule(this);
// set our medialist to be the same as the sheet's medialist
nsCOMPtr<nsIDOMMediaList> mediaList;
rv = mChildSheet->GetMedia(getter_AddRefs(mediaList));
NS_ENSURE_SUCCESS(rv, rv);
mChildSheet->GetMedia(getter_AddRefs(mediaList));
NS_ABORT_IF_FALSE(mediaList, "GetMedia returned null");
mMedia = static_cast<nsMediaList*>(mediaList.get());
return NS_OK;
}
NS_IMETHODIMP

View File

@ -2069,15 +2069,11 @@ nsCSSStyleSheet::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
"We are being notified of a sheet load for a sheet that is not our child!");
if (mDocument && NS_SUCCEEDED(aStatus)) {
nsRefPtr<css::ImportRule> ownerRule = aSheet->GetOwnerRule();
mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE);
// XXXldb @import rules shouldn't even implement nsIStyleRule (but
// they do)!
nsIStyleRule* styleRule = ownerRule;
mDocument->StyleRuleAdded(this, styleRule);
mDocument->StyleRuleAdded(this, aSheet->GetOwnerRule());
}
return NS_OK;