Bug 577974 - Part 2: Remove nsICSSGroupRule, r=bzbarsky

--HG--
rename : layout/style/nsICSSGroupRule.h => layout/style/GroupRule.h
This commit is contained in:
Craig Topper 2010-08-07 22:28:33 -07:00
parent 2f31a02e26
commit 3265d1070e
12 changed files with 190 additions and 191 deletions

View File

@ -40,47 +40,89 @@
* rules, such as @media rules
*/
#ifndef nsICSSGroupRule_h
#define nsICSSGroupRule_h
#ifndef mozilla_css_GroupRule_h__
#define mozilla_css_GroupRule_h__
#include "nsICSSRule.h"
#include "nsCSSRule.h"
#include "nsCOMArray.h"
#include "nsAutoPtr.h"
class nsPresContext;
class nsMediaQueryResultCacheKey;
#define NS_ICSS_GROUP_RULE_IID \
{ 0xf1e3d96b, 0xe381, 0x4533, \
{ 0xa6, 0x5e, 0xa5, 0x31, 0xba, 0xca, 0x93, 0x62 } }
namespace mozilla {
namespace css {
class GroupRuleRuleList;
class nsICSSGroupRule : public nsICSSRule {
// inherits from nsCSSRule so it can be shared between
// nsCSSMediaRule and nsCSSDocumentRule
class GroupRule : public nsCSSRule, public nsICSSRule
{
protected:
GroupRule();
GroupRule(const GroupRule& aCopy);
virtual ~GroupRule();
protected:
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_GROUP_RULE_IID)
NS_IMETHOD AppendStyleRule(nsICSSRule* aRule) = 0;
// Implement part of nsISupports.
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
NS_IMETHOD StyleRuleCount(PRInt32& aCount) const = 0;
NS_IMETHOD GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const = 0;
// implement part of nsIStyleRule and nsICSSRule
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
// to help implement nsIStyleRule
#ifdef DEBUG
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
#endif
public:
NS_IMETHOD AppendStyleRule(nsICSSRule* aRule);
NS_IMETHOD StyleRuleCount(PRInt32& aCount) const;
NS_IMETHOD GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const;
typedef nsCOMArray<nsICSSRule>::nsCOMArrayEnumFunc RuleEnumFunc;
NS_IMETHOD_(PRBool) EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const = 0;
NS_IMETHOD_(PRBool) EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const;
/*
* The next three methods should never be called unless you have first
* called WillDirty() on the parent stylesheet. After they are
* called, DidDirty() needs to be called on the sheet.
*/
NS_IMETHOD DeleteStyleRuleAt(PRUint32 aIndex) = 0;
NS_IMETHOD DeleteStyleRuleAt(PRUint32 aIndex);
NS_IMETHOD InsertStyleRulesAt(PRUint32 aIndex,
nsCOMArray<nsICSSRule>& aRules) = 0;
NS_IMETHOD ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew) = 0;
nsCOMArray<nsICSSRule>& aRules);
NS_IMETHOD ReplaceStyleRule(nsICSSRule *aOld, nsICSSRule *aNew);
NS_IMETHOD_(PRBool) UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey) = 0;
protected:
// to help implement nsIDOMCSSRule
nsresult AppendRulesToCssText(nsAString& aCssText);
// to implement methods on nsIDOMCSSRule
nsresult GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet);
nsresult GetParentRule(nsIDOMCSSRule** aParentRule);
// to implement common methods on nsIDOMCSSMediaRule and
// nsIDOMCSSMozDocumentRule
nsresult GetCssRules(nsIDOMCSSRuleList* *aRuleList);
nsresult InsertRule(const nsAString & aRule, PRUint32 aIndex,
PRUint32* _retval);
nsresult DeleteRule(PRUint32 aIndex);
nsCOMArray<nsICSSRule> mRules;
nsRefPtr<GroupRuleRuleList> mRuleCollection; // lazily constructed
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSGroupRule, NS_ICSS_GROUP_RULE_IID)
} // namespace css
} // namespace mozilla
#endif /* nsICSSGroupRule_h */
#endif /* mozilla_css_GroupRule_h__ */

View File

@ -72,7 +72,6 @@ EXPORTS = \
nsDOMCSSAttrDeclaration.h \
nsDOMCSSDeclaration.h \
nsICSSDeclaration.h \
nsICSSGroupRule.h \
nsICSSLoaderObserver.h \
nsICSSPseudoComparator.h \
nsICSSRule.h \
@ -99,6 +98,7 @@ EXPORTS = \
EXPORTS_mozilla/css = \
Declaration.h \
GroupRule.h \
ImportRule.h \
Loader.h \
NameSpaceRule.h \

View File

@ -45,7 +45,7 @@
*/
#include "mozilla/css/StyleRule.h"
#include "nsICSSGroupRule.h"
#include "mozilla/css/GroupRule.h"
#include "mozilla/css/Declaration.h"
#include "nsCSSStyleSheet.h"
#include "mozilla/css/Loader.h"
@ -1225,7 +1225,7 @@ DOMCSSStyleRule::GetParentRule(nsIDOMCSSRule** aParentRule)
*aParentRule = nsnull;
return NS_OK;
}
nsICSSGroupRule* rule = Rule()->GetParentRule();
GroupRule* rule = Rule()->GetParentRule();
if (!rule) {
*aParentRule = nsnull;
return NS_OK;
@ -1390,7 +1390,7 @@ StyleRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
}
/* virtual */ void
StyleRule::SetParentRule(nsICSSGroupRule* aRule)
StyleRule::SetParentRule(GroupRule* aRule)
{
nsCSSRule::SetParentRule(aRule);
}

View File

@ -343,7 +343,7 @@ public:
void GetCssText(nsAString& aCssText);
void SetCssText(const nsAString& aCssText);
nsCSSStyleSheet* GetParentStyleSheet() { return mSheet; }
nsICSSGroupRule* GetParentRule() { return mParentRule; }
GroupRule* GetParentRule() { return mParentRule; }
void GetSelectorText(nsAString& aSelectorText);
void SetSelectorText(const nsAString& aSelectorText);
@ -351,7 +351,7 @@ public:
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
virtual void SetParentRule(nsICSSGroupRule* aRule);
virtual void SetParentRule(GroupRule* aRule);
virtual already_AddRefed<nsICSSRule> Clone() const;

View File

@ -323,8 +323,8 @@ protected:
PRBool SkipAtRule(PRBool aInsideBlock);
PRBool SkipDeclaration(PRBool aCheckForBraces);
PRBool PushGroup(nsICSSGroupRule* aRule);
void PopGroup(void);
PRBool PushGroup(css::GroupRule* aRule);
void PopGroup();
PRBool ParseRuleSet(RuleAppendFunc aAppendFunc, void* aProcessData,
PRBool aInsideBraces = PR_FALSE);
@ -341,7 +341,7 @@ protected:
nsMediaList* aMedia,
RuleAppendFunc aAppendFunc,
void* aProcessData);
PRBool ParseGroupRule(nsICSSGroupRule* aRule, RuleAppendFunc aAppendFunc,
PRBool ParseGroupRule(css::GroupRule* aRule, RuleAppendFunc aAppendFunc,
void* aProcessData);
PRBool ParseMediaRule(RuleAppendFunc aAppendFunc, void* aProcessData);
PRBool ParseMozDocumentRule(RuleAppendFunc aAppendFunc, void* aProcessData);
@ -656,7 +656,7 @@ protected:
#endif
// Stack of rule groups; used for @media and such.
nsCOMArray<nsICSSGroupRule> mGroupStack;
nsTArray<nsRefPtr<css::GroupRule> > mGroupStack;
// During the parsing of a property (which may be a shorthand), the data
// are stored in |mTempData|. (It is needed to ensure that parser
@ -1958,7 +1958,7 @@ CSSParserImpl::ProcessImport(const nsString& aURLSpec,
// Parse the {} part of an @media or @-moz-document rule.
PRBool
CSSParserImpl::ParseGroupRule(nsICSSGroupRule* aRule,
CSSParserImpl::ParseGroupRule(css::GroupRule* aRule,
RuleAppendFunc aAppendFunc,
void* aData)
{
@ -2386,27 +2386,27 @@ CSSParserImpl::SkipRuleSet(PRBool aInsideBraces)
}
PRBool
CSSParserImpl::PushGroup(nsICSSGroupRule* aRule)
CSSParserImpl::PushGroup(css::GroupRule* aRule)
{
if (mGroupStack.AppendObject(aRule))
if (mGroupStack.AppendElement(aRule))
return PR_TRUE;
return PR_FALSE;
}
void
CSSParserImpl::PopGroup(void)
CSSParserImpl::PopGroup()
{
PRInt32 count = mGroupStack.Count();
PRUint32 count = mGroupStack.Length();
if (0 < count) {
mGroupStack.RemoveObjectAt(count - 1);
mGroupStack.RemoveElementAt(count - 1);
}
}
void
CSSParserImpl::AppendRule(nsICSSRule* aRule)
{
PRInt32 count = mGroupStack.Count();
PRUint32 count = mGroupStack.Length();
if (0 < count) {
mGroupStack[count - 1]->AppendStyleRule(aRule);
}

View File

@ -44,7 +44,26 @@
#include "nsCOMPtr.h"
#include "nsCSSStyleSheet.h"
class nsICSSGroupRule;
class nsIStyleSheet;
class nsCSSStyleSheet;
struct nsRuleData;
template<class T> struct already_AddRefed;
namespace mozilla {
namespace css {
class GroupRule;
}
}
#define DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const; \
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); \
virtual void SetParentRule(mozilla::css::GroupRule* aRule); \
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
#define DECL_STYLE_RULE_INHERIT \
DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
class nsCSSRule {
public:
@ -77,7 +96,7 @@ public:
}
void
SetParentRule(nsICSSGroupRule* aRule)
SetParentRule(mozilla::css::GroupRule* aRule)
{
// We don't reference count this up reference. The group rule
// will tell us when it's going away or when we're detached from
@ -86,8 +105,8 @@ public:
}
protected:
nsCSSStyleSheet* mSheet;
nsICSSGroupRule* mParentRule;
nsCSSStyleSheet* mSheet;
mozilla::css::GroupRule* mParentRule;
};
#endif /* nsCSSRule_h___ */

View File

@ -59,7 +59,7 @@
#include "nsICSSPseudoComparator.h"
#include "nsCSSRuleProcessor.h"
#include "mozilla/css/StyleRule.h"
#include "nsICSSGroupRule.h"
#include "mozilla/css/GroupRule.h"
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsIEventStateManager.h"
@ -2782,7 +2782,7 @@ CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData)
}
else if (nsICSSRule::MEDIA_RULE == type ||
nsICSSRule::DOCUMENT_RULE == type) {
nsICSSGroupRule* groupRule = (nsICSSGroupRule*)aRule;
css::GroupRule* groupRule = static_cast<css::GroupRule*>(aRule);
if (groupRule->UseForPresentation(data->mPresContext, data->mCacheKey))
if (!groupRule->EnumerateRulesForwards(CascadeRuleEnumFunc, aData))
return PR_FALSE;

View File

@ -73,13 +73,13 @@ namespace css = mozilla::css;
#define IMPL_STYLE_RULE_INHERIT(_class, super) \
/* virtual */ already_AddRefed<nsIStyleSheet> _class::GetStyleSheet() const { return super::GetStyleSheet(); } \
/* virtual */ void _class::SetStyleSheet(nsCSSStyleSheet* aSheet) { super::SetStyleSheet(aSheet); } \
/* virtual */ void _class::SetParentRule(nsICSSGroupRule* aRule) { super::SetParentRule(aRule); } \
/* virtual */ void _class::SetParentRule(css::GroupRule* aRule) { super::SetParentRule(aRule); } \
nsIDOMCSSRule* _class::GetDOMRuleWeak(nsresult *aResult) { *aResult = NS_OK; return this; } \
/* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
#define IMPL_STYLE_RULE_INHERIT2(_class, super) \
/* virtual */ already_AddRefed<nsIStyleSheet> _class::GetStyleSheet() const { return super::GetStyleSheet(); } \
/* virtual */ void _class::SetParentRule(nsICSSGroupRule* aRule) { super::SetParentRule(aRule); } \
/* virtual */ void _class::SetParentRule(css::GroupRule* aRule) { super::SetParentRule(aRule); } \
/* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
// -------------------------------
@ -92,7 +92,7 @@ namespace css {
class NS_FINAL_CLASS GroupRuleRuleList : public nsICSSRuleList
{
public:
GroupRuleRuleList(nsICSSGroupRule *aGroupRule);
GroupRuleRuleList(GroupRule *aGroupRule);
NS_DECL_ISUPPORTS
@ -106,10 +106,10 @@ private:
~GroupRuleRuleList();
private:
nsICSSGroupRule* mGroupRule;
GroupRule* mGroupRule;
};
GroupRuleRuleList::GroupRuleRuleList(nsICSSGroupRule *aGroupRule)
GroupRuleRuleList::GroupRuleRuleList(GroupRule *aGroupRule)
{
// Not reference counted to avoid circular references.
// The rule will tell us when its going away.
@ -576,11 +576,6 @@ NS_NewCSSImportRule(css::ImportRule** aInstancePtrResult,
return NS_OK;
}
nsCSSGroupRule::nsCSSGroupRule()
: nsCSSRule()
{
}
static PRBool
CloneRuleInto(nsICSSRule* aRule, void* aArray)
{
@ -589,22 +584,30 @@ CloneRuleInto(nsICSSRule* aRule, void* aArray)
return PR_TRUE;
}
namespace mozilla {
namespace css {
GroupRule::GroupRule()
: nsCSSRule()
{
}
static PRBool
SetParentRuleReference(nsICSSRule* aRule, void* aParentRule)
{
nsCSSGroupRule* parentRule = static_cast<nsCSSGroupRule*>(aParentRule);
GroupRule* parentRule = static_cast<GroupRule*>(aParentRule);
aRule->SetParentRule(parentRule);
return PR_TRUE;
}
nsCSSGroupRule::nsCSSGroupRule(const nsCSSGroupRule& aCopy)
GroupRule::GroupRule(const GroupRule& aCopy)
: nsCSSRule(aCopy)
{
const_cast<nsCSSGroupRule&>(aCopy).mRules.EnumerateForwards(CloneRuleInto, &mRules);
const_cast<GroupRule&>(aCopy).mRules.EnumerateForwards(CloneRuleInto, &mRules);
mRules.EnumerateForwards(SetParentRuleReference, this);
}
nsCSSGroupRule::~nsCSSGroupRule()
GroupRule::~GroupRule()
{
mRules.EnumerateForwards(SetParentRuleReference, nsnull);
if (mRuleCollection) {
@ -612,10 +615,10 @@ nsCSSGroupRule::~nsCSSGroupRule()
}
}
NS_IMPL_ADDREF(nsCSSGroupRule)
NS_IMPL_RELEASE(nsCSSGroupRule)
NS_IMPL_ADDREF(GroupRule)
NS_IMPL_RELEASE(GroupRule)
IMPL_STYLE_RULE_INHERIT2(nsCSSGroupRule, nsCSSRule)
IMPL_STYLE_RULE_INHERIT2(GroupRule, nsCSSRule)
static PRBool
SetStyleSheetReference(nsICSSRule* aRule, void* aSheet)
@ -626,7 +629,7 @@ SetStyleSheetReference(nsICSSRule* aRule, void* aSheet)
}
/* virtual */ void
nsCSSGroupRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
GroupRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
{
mRules.EnumerateForwards(SetStyleSheetReference, aSheet);
nsCSSRule::SetStyleSheet(aSheet);
@ -634,7 +637,7 @@ nsCSSGroupRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
#ifdef DEBUG
/* virtual */ void
nsCSSGroupRule::List(FILE* out, PRInt32 aIndent) const
GroupRule::List(FILE* out, PRInt32 aIndent) const
{
fputs(" {\n", out);
@ -646,7 +649,7 @@ nsCSSGroupRule::List(FILE* out, PRInt32 aIndent) const
#endif
NS_IMETHODIMP
nsCSSGroupRule::AppendStyleRule(nsICSSRule* aRule)
GroupRule::AppendStyleRule(nsICSSRule* aRule)
{
mRules.AppendObject(aRule);
aRule->SetStyleSheet(mSheet);
@ -660,14 +663,14 @@ nsCSSGroupRule::AppendStyleRule(nsICSSRule* aRule)
}
NS_IMETHODIMP
nsCSSGroupRule::StyleRuleCount(PRInt32& aCount) const
GroupRule::StyleRuleCount(PRInt32& aCount) const
{
aCount = mRules.Count();
return NS_OK;
}
NS_IMETHODIMP
nsCSSGroupRule::GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const
GroupRule::GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const
{
if (aIndex < 0 || aIndex >= mRules.Count()) {
aRule = nsnull;
@ -679,10 +682,10 @@ nsCSSGroupRule::GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const
}
NS_IMETHODIMP_(PRBool)
nsCSSGroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const
GroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const
{
return
const_cast<nsCSSGroupRule*>(this)->mRules.EnumerateForwards(aFunc, aData);
const_cast<GroupRule*>(this)->mRules.EnumerateForwards(aFunc, aData);
}
/*
@ -692,7 +695,7 @@ nsCSSGroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const
* be called on the sheet
*/
NS_IMETHODIMP
nsCSSGroupRule::DeleteStyleRuleAt(PRUint32 aIndex)
GroupRule::DeleteStyleRuleAt(PRUint32 aIndex)
{
nsICSSRule* rule = mRules.SafeObjectAt(aIndex);
if (rule) {
@ -703,8 +706,8 @@ nsCSSGroupRule::DeleteStyleRuleAt(PRUint32 aIndex)
}
NS_IMETHODIMP
nsCSSGroupRule::InsertStyleRulesAt(PRUint32 aIndex,
nsCOMArray<nsICSSRule>& aRules)
GroupRule::InsertStyleRulesAt(PRUint32 aIndex,
nsCOMArray<nsICSSRule>& aRules)
{
aRules.EnumerateForwards(SetStyleSheetReference, mSheet);
aRules.EnumerateForwards(SetParentRuleReference, this);
@ -715,7 +718,7 @@ nsCSSGroupRule::InsertStyleRulesAt(PRUint32 aIndex,
}
NS_IMETHODIMP
nsCSSGroupRule::ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew)
GroupRule::ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew)
{
PRInt32 index = mRules.IndexOf(aOld);
NS_ENSURE_TRUE(index != -1, NS_ERROR_UNEXPECTED);
@ -728,7 +731,7 @@ nsCSSGroupRule::ReplaceStyleRule(nsICSSRule* aOld, nsICSSRule* aNew)
}
nsresult
nsCSSGroupRule::AppendRulesToCssText(nsAString& aCssText)
GroupRule::AppendRulesToCssText(nsAString& aCssText)
{
aCssText.AppendLiteral(" {\n");
@ -752,14 +755,14 @@ nsCSSGroupRule::AppendRulesToCssText(nsAString& aCssText)
}
nsresult
nsCSSGroupRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
GroupRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
{
NS_IF_ADDREF(*aSheet = mSheet);
return NS_OK;
}
nsresult
nsCSSGroupRule::GetParentRule(nsIDOMCSSRule** aParentRule)
GroupRule::GetParentRule(nsIDOMCSSRule** aParentRule)
{
if (mParentRule) {
return mParentRule->GetDOMRule(aParentRule);
@ -770,7 +773,7 @@ nsCSSGroupRule::GetParentRule(nsIDOMCSSRule** aParentRule)
// nsIDOMCSSMediaRule or nsIDOMCSSMozDocumentRule methods
nsresult
nsCSSGroupRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
GroupRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
{
if (!mRuleCollection) {
mRuleCollection = new css::GroupRuleRuleList(this);
@ -781,7 +784,7 @@ nsCSSGroupRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
}
nsresult
nsCSSGroupRule::InsertRule(const nsAString & aRule, PRUint32 aIndex, PRUint32* _retval)
GroupRule::InsertRule(const nsAString & aRule, PRUint32 aIndex, PRUint32* _retval)
{
NS_ENSURE_TRUE(mSheet, NS_ERROR_FAILURE);
@ -795,7 +798,7 @@ nsCSSGroupRule::InsertRule(const nsAString & aRule, PRUint32 aIndex, PRUint32* _
}
nsresult
nsCSSGroupRule::DeleteRule(PRUint32 aIndex)
GroupRule::DeleteRule(PRUint32 aIndex)
{
NS_ENSURE_TRUE(mSheet, NS_ERROR_FAILURE);
@ -808,6 +811,9 @@ nsCSSGroupRule::DeleteRule(PRUint32 aIndex)
return mSheet->DeleteRuleFromGroup(this, aIndex);
}
} // namespace css
} // namespace mozilla
// -------------------------------------------
// nsICSSMediaRule
//
@ -816,7 +822,7 @@ nsCSSMediaRule::nsCSSMediaRule()
}
nsCSSMediaRule::nsCSSMediaRule(const nsCSSMediaRule& aCopy)
: nsCSSGroupRule(aCopy)
: GroupRule(aCopy)
{
if (aCopy.mMedia) {
aCopy.mMedia->Clone(getter_AddRefs(mMedia));
@ -834,19 +840,18 @@ nsCSSMediaRule::~nsCSSMediaRule()
}
}
NS_IMPL_ADDREF_INHERITED(nsCSSMediaRule, nsCSSGroupRule)
NS_IMPL_RELEASE_INHERITED(nsCSSMediaRule, nsCSSGroupRule)
NS_IMPL_ADDREF_INHERITED(nsCSSMediaRule, GroupRule)
NS_IMPL_RELEASE_INHERITED(nsCSSMediaRule, GroupRule)
DOMCI_DATA(CSSMediaRule, nsCSSMediaRule)
// QueryInterface implementation for nsCSSMediaRule
NS_INTERFACE_MAP_BEGIN(nsCSSMediaRule)
NS_INTERFACE_MAP_ENTRY(nsICSSGroupRule)
NS_INTERFACE_MAP_ENTRY(nsICSSRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMediaRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsCSSGroupRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMediaRule)
NS_INTERFACE_MAP_END
@ -859,7 +864,7 @@ nsCSSMediaRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
mMedia->SetStyleSheet(aSheet);
}
nsCSSGroupRule::SetStyleSheet(aSheet);
GroupRule::SetStyleSheet(aSheet);
}
#ifdef DEBUG
@ -878,7 +883,7 @@ nsCSSMediaRule::List(FILE* out, PRInt32 aIndent) const
fputs(NS_LossyConvertUTF16toASCII(mediaText).get(), out);
}
nsCSSGroupRule::List(out, aIndent);
GroupRule::List(out, aIndent);
}
#endif
@ -923,7 +928,7 @@ nsCSSMediaRule::GetCssText(nsAString& aCssText)
aCssText.Append(mediaText);
}
return nsCSSGroupRule::AppendRulesToCssText(aCssText);
return GroupRule::AppendRulesToCssText(aCssText);
}
NS_IMETHODIMP
@ -935,13 +940,13 @@ nsCSSMediaRule::SetCssText(const nsAString& aCssText)
NS_IMETHODIMP
nsCSSMediaRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
{
return nsCSSGroupRule::GetParentStyleSheet(aSheet);
return GroupRule::GetParentStyleSheet(aSheet);
}
NS_IMETHODIMP
nsCSSMediaRule::GetParentRule(nsIDOMCSSRule** aParentRule)
{
return nsCSSGroupRule::GetParentRule(aParentRule);
return GroupRule::GetParentRule(aParentRule);
}
// nsIDOMCSSMediaRule methods
@ -956,22 +961,22 @@ nsCSSMediaRule::GetMedia(nsIDOMMediaList* *aMedia)
NS_IMETHODIMP
nsCSSMediaRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
{
return nsCSSGroupRule::GetCssRules(aRuleList);
return GroupRule::GetCssRules(aRuleList);
}
NS_IMETHODIMP
nsCSSMediaRule::InsertRule(const nsAString & aRule, PRUint32 aIndex, PRUint32* _retval)
{
return nsCSSGroupRule::InsertRule(aRule, aIndex, _retval);
return GroupRule::InsertRule(aRule, aIndex, _retval);
}
NS_IMETHODIMP
nsCSSMediaRule::DeleteRule(PRUint32 aIndex)
{
return nsCSSGroupRule::DeleteRule(aIndex);
return GroupRule::DeleteRule(aIndex);
}
// nsICSSGroupRule interface
// GroupRule interface
NS_IMETHODIMP_(PRBool)
nsCSSMediaRule::UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey)
@ -988,7 +993,7 @@ nsCSSDocumentRule::nsCSSDocumentRule(void)
}
nsCSSDocumentRule::nsCSSDocumentRule(const nsCSSDocumentRule& aCopy)
: nsCSSGroupRule(aCopy)
: GroupRule(aCopy)
, mURLs(new URL(*aCopy.mURLs))
{
}
@ -997,19 +1002,18 @@ nsCSSDocumentRule::~nsCSSDocumentRule(void)
{
}
NS_IMPL_ADDREF_INHERITED(nsCSSDocumentRule, nsCSSGroupRule)
NS_IMPL_RELEASE_INHERITED(nsCSSDocumentRule, nsCSSGroupRule)
NS_IMPL_ADDREF_INHERITED(nsCSSDocumentRule, GroupRule)
NS_IMPL_RELEASE_INHERITED(nsCSSDocumentRule, GroupRule)
DOMCI_DATA(CSSMozDocumentRule, nsCSSDocumentRule)
// QueryInterface implementation for nsCSSDocumentRule
NS_INTERFACE_MAP_BEGIN(nsCSSDocumentRule)
NS_INTERFACE_MAP_ENTRY(nsICSSGroupRule)
NS_INTERFACE_MAP_ENTRY(nsICSSRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsCSSGroupRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSMozDocumentRule)
NS_INTERFACE_MAP_END
@ -1041,7 +1045,7 @@ nsCSSDocumentRule::List(FILE* out, PRInt32 aIndent) const
str.Cut(str.Length() - 2, 1); // remove last ,
fputs(str.get(), out);
nsCSSGroupRule::List(out, aIndent);
GroupRule::List(out, aIndent);
}
#endif
@ -1089,7 +1093,7 @@ nsCSSDocumentRule::GetCssText(nsAString& aCssText)
}
aCssText.Cut(aCssText.Length() - 2, 1); // remove last ,
return nsCSSGroupRule::AppendRulesToCssText(aCssText);
return GroupRule::AppendRulesToCssText(aCssText);
}
NS_IMETHODIMP
@ -1101,34 +1105,34 @@ nsCSSDocumentRule::SetCssText(const nsAString& aCssText)
NS_IMETHODIMP
nsCSSDocumentRule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
{
return nsCSSGroupRule::GetParentStyleSheet(aSheet);
return GroupRule::GetParentStyleSheet(aSheet);
}
NS_IMETHODIMP
nsCSSDocumentRule::GetParentRule(nsIDOMCSSRule** aParentRule)
{
return nsCSSGroupRule::GetParentRule(aParentRule);
return GroupRule::GetParentRule(aParentRule);
}
NS_IMETHODIMP
nsCSSDocumentRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
{
return nsCSSGroupRule::GetCssRules(aRuleList);
return GroupRule::GetCssRules(aRuleList);
}
NS_IMETHODIMP
nsCSSDocumentRule::InsertRule(const nsAString & aRule, PRUint32 aIndex, PRUint32* _retval)
{
return nsCSSGroupRule::InsertRule(aRule, aIndex, _retval);
return GroupRule::InsertRule(aRule, aIndex, _retval);
}
NS_IMETHODIMP
nsCSSDocumentRule::DeleteRule(PRUint32 aIndex)
{
return nsCSSGroupRule::DeleteRule(aIndex);
return GroupRule::DeleteRule(aIndex);
}
// nsICSSGroupRule interface
// GroupRule interface
NS_IMETHODIMP_(PRBool)
nsCSSDocumentRule::UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey)

View File

@ -44,7 +44,7 @@
#define nsCSSRules_h_
#include "nsCSSRule.h"
#include "nsICSSGroupRule.h"
#include "mozilla/css/GroupRule.h"
#include "nsIDOMCSSMediaRule.h"
#include "nsIDOMCSSMozDocumentRule.h"
#include "nsIDOMCSSFontFaceRule.h"
@ -54,79 +54,8 @@
#include "nsCSSValue.h"
class nsMediaList;
template<class T> struct already_AddRefed;
namespace mozilla {
namespace css {
class GroupRuleRuleList;
}
}
#define DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const; \
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); \
virtual void SetParentRule(nsICSSGroupRule* aRule); \
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
#define DECL_STYLE_RULE_INHERIT \
DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
// inherits from nsCSSRule and also implements methods on nsICSSGroupRule
// so they can be shared between nsCSSMediaRule and nsCSSDocumentRule
class nsCSSGroupRule : public nsCSSRule, public nsICSSGroupRule
{
protected:
nsCSSGroupRule();
nsCSSGroupRule(const nsCSSGroupRule& aCopy);
virtual ~nsCSSGroupRule();
// Implement part of nsISupports.
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
protected:
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
public:
// implement part of nsIStyleRule and nsICSSRule
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
// to help implement nsIStyleRule
#ifdef DEBUG
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
#endif
public:
// implement nsICSSGroupRule
NS_IMETHOD AppendStyleRule(nsICSSRule* aRule);
NS_IMETHOD StyleRuleCount(PRInt32& aCount) const;
NS_IMETHOD GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const;
NS_IMETHOD_(PRBool) EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const;
NS_IMETHOD DeleteStyleRuleAt(PRUint32 aIndex);
NS_IMETHOD InsertStyleRulesAt(PRUint32 aIndex,
nsCOMArray<nsICSSRule>& aRules);
NS_IMETHOD ReplaceStyleRule(nsICSSRule *aOld, nsICSSRule *aNew);
protected:
// to help implement nsIDOMCSSRule
nsresult AppendRulesToCssText(nsAString& aCssText);
// to implement methods on nsIDOMCSSRule
nsresult GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet);
nsresult GetParentRule(nsIDOMCSSRule** aParentRule);
// to implement common methods on nsIDOMCSSMediaRule and
// nsIDOMCSSMozDocumentRule
nsresult GetCssRules(nsIDOMCSSRuleList* *aRuleList);
nsresult InsertRule(const nsAString & aRule, PRUint32 aIndex,
PRUint32* _retval);
nsresult DeleteRule(PRUint32 aIndex);
nsCOMArray<nsICSSRule> mRules;
nsRefPtr<mozilla::css::GroupRuleRuleList> mRuleCollection; // lazily constructed
};
class NS_FINAL_CLASS nsCSSMediaRule : public nsCSSGroupRule,
class NS_FINAL_CLASS nsCSSMediaRule : public mozilla::css::GroupRule,
public nsIDOMCSSMediaRule
{
public:
@ -142,7 +71,7 @@ public:
#endif
// nsICSSRule methods
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override nsCSSGroupRule
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule
virtual PRInt32 GetType() const;
virtual already_AddRefed<nsICSSRule> Clone() const;
nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult)
@ -157,7 +86,7 @@ public:
// nsIDOMCSSMediaRule interface
NS_DECL_NSIDOMCSSMEDIARULE
// rest of nsICSSGroupRule interface
// rest of GroupRule
NS_IMETHOD_(PRBool) UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey);
@ -168,7 +97,7 @@ protected:
nsRefPtr<nsMediaList> mMedia;
};
class NS_FINAL_CLASS nsCSSDocumentRule : public nsCSSGroupRule,
class NS_FINAL_CLASS nsCSSDocumentRule : public mozilla::css::GroupRule,
public nsIDOMCSSMozDocumentRule
{
public:
@ -198,7 +127,7 @@ public:
// nsIDOMCSSMozDocumentRule interface
NS_DECL_NSIDOMCSSMOZDOCUMENTRULE
// rest of nsICSSGroupRule interface
// rest of GroupRule
NS_IMETHOD_(PRBool) UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey);

View File

@ -47,7 +47,7 @@
#include "nsIAtom.h"
#include "nsCSSRuleProcessor.h"
#include "mozilla/css/NameSpaceRule.h"
#include "nsICSSGroupRule.h"
#include "mozilla/css/GroupRule.h"
#include "mozilla/css/ImportRule.h"
#include "nsIMediaList.h"
#include "nsIDocument.h"
@ -1934,7 +1934,7 @@ nsCSSStyleSheet::DeleteRule(PRUint32 aIndex)
}
nsresult
nsCSSStyleSheet::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
nsCSSStyleSheet::DeleteRuleFromGroup(css::GroupRule* aGroup, PRUint32 aIndex)
{
NS_ENSURE_ARG_POINTER(aGroup);
NS_ASSERTION(mInner->mComplete, "No deleting from an incomplete sheet!");
@ -1970,7 +1970,7 @@ nsCSSStyleSheet::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
nsresult
nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule,
nsICSSGroupRule* aGroup,
css::GroupRule* aGroup,
PRUint32 aIndex,
PRUint32* _retval)
{
@ -2043,7 +2043,7 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule,
}
nsresult
nsCSSStyleSheet::ReplaceRuleInGroup(nsICSSGroupRule* aGroup,
nsCSSStyleSheet::ReplaceRuleInGroup(css::GroupRule* aGroup,
nsICSSRule* aOld, nsICSSRule* aNew)
{
nsresult result;

View File

@ -56,7 +56,6 @@ class nsICSSRule;
class nsXMLNameSpaceMap;
class nsCSSRuleProcessor;
class nsMediaList;
class nsICSSGroupRule;
class nsIPrincipal;
class nsIURI;
class nsMediaList;
@ -67,6 +66,7 @@ template<class E, class A> class nsTArray;
namespace mozilla {
namespace css {
class GroupRule;
class ImportRule;
}
}
@ -172,9 +172,9 @@ public:
PRInt32 StyleRuleCount() const;
nsresult GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const;
nsresult DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex);
nsresult InsertRuleIntoGroup(const nsAString& aRule, nsICSSGroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval);
nsresult ReplaceRuleInGroup(nsICSSGroupRule* aGroup, nsICSSRule* aOld, nsICSSRule* aNew);
nsresult DeleteRuleFromGroup(mozilla::css::GroupRule* aGroup, PRUint32 aIndex);
nsresult InsertRuleIntoGroup(const nsAString& aRule, mozilla::css::GroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval);
nsresult ReplaceRuleInGroup(mozilla::css::GroupRule* aGroup, nsICSSRule* aOld, nsICSSRule* aNew);
PRInt32 StyleSheetCount() const;

View File

@ -44,15 +44,20 @@
#include "nsIDOMCSSRule.h"
class nsCSSStyleSheet;
class nsICSSGroupRule;
class nsAString;
template<class T> struct already_AddRefed;
class nsIStyleSheet;
namespace mozilla {
namespace css {
class GroupRule;
}
}
// IID for the nsICSSRule interface
#define NS_ICSS_RULE_IID \
{ 0x1f560b20, 0xa829, 0x4b99, \
{ 0x87, 0xbd, 0x8c, 0x87, 0x95, 0x2b, 0x3b, 0xb6 } }
#define NS_ICSS_RULE_IID \
{ 0x471d733e, 0xc138, 0x4a50, \
{ 0x9e, 0x1a, 0xd1, 0x3c, 0xbb, 0x65, 0xb5, 0x26 } }
// inheriting from nsIStyleRule is only for style rules, not other rule types
@ -80,7 +85,7 @@ public:
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const = 0;
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet) = 0;
virtual void SetParentRule(nsICSSGroupRule* aRule) = 0;
virtual void SetParentRule(mozilla::css::GroupRule* aRule) = 0;
/**
* Clones |this|. Never returns NULL.