Bug 576831 part 4. Remove nsICSSStyleRule and use mozilla::css::StyleRule instead. r=bzbarsky

--HG--
rename : layout/style/nsCSSStyleRule.cpp => layout/style/StyleRule.cpp
rename : layout/style/nsICSSStyleRule.h => layout/style/StyleRule.h
This commit is contained in:
Craig Topper 2011-03-10 21:48:57 -05:00
parent 952a977004
commit 678b9c7c11
31 changed files with 250 additions and 254 deletions

View File

@ -50,7 +50,6 @@ class nsIDOMEvent;
class nsIContent; class nsIContent;
class nsIEventListenerManager; class nsIEventListenerManager;
class nsIURI; class nsIURI;
class nsICSSStyleRule;
class nsRuleWalker; class nsRuleWalker;
class nsAttrValue; class nsAttrValue;
class nsAttrName; class nsAttrName;
@ -62,6 +61,12 @@ class nsISMILAttr;
class nsIDOMCSSStyleDeclaration; class nsIDOMCSSStyleDeclaration;
#endif // MOZ_SMIL #endif // MOZ_SMIL
namespace mozilla {
namespace css {
class StyleRule;
}
}
enum nsLinkState { enum nsLinkState {
eLinkState_Unknown = 0, eLinkState_Unknown = 0,
eLinkState_Unvisited = 1, eLinkState_Unvisited = 1,
@ -71,8 +76,8 @@ enum nsLinkState {
// IID for the nsIContent interface // IID for the nsIContent interface
#define NS_ICONTENT_IID \ #define NS_ICONTENT_IID \
{ 0x71afb9e6, 0xe8a7, 0x475d, \ { 0x557a7d96, 0xb9cd, 0x4be2, \
{ 0x89, 0xc4, 0xe4, 0x62, 0x21, 0xeb, 0xe1, 0xa4 } } { 0xa3, 0xe7, 0x5f, 0x43, 0x6d, 0xfd, 0xd9, 0x4f } }
/** /**
* A node of content in a document's content model. This interface * A node of content in a document's content model. This interface
@ -823,13 +828,13 @@ public:
/** /**
* Get the inline style rule, if any, for this content node * Get the inline style rule, if any, for this content node
*/ */
virtual nsICSSStyleRule* GetInlineStyleRule() = 0; virtual mozilla::css::StyleRule* GetInlineStyleRule() = 0;
/** /**
* Set the inline style rule for this node. This will send an * Set the inline style rule for this node. This will send an
* appropriate AttributeChanged notification if aNotify is true. * appropriate AttributeChanged notification if aNotify is true.
*/ */
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify) = 0; NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, PRBool aNotify) = 0;
/** /**
* Is the attribute named stored in the mapped attributes? * Is the attribute named stored in the mapped attributes?
@ -916,14 +921,14 @@ public:
* hasn't been created (or if this nsIContent object doesn't support SMIL * hasn't been created (or if this nsIContent object doesn't support SMIL
* override style), this method simply returns null. * override style), this method simply returns null.
*/ */
virtual nsICSSStyleRule* GetSMILOverrideStyleRule() = 0; virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule() = 0;
/** /**
* Set the SMIL override style rule for this node. If aNotify is true, this * Set the SMIL override style rule for this node. If aNotify is true, this
* method will notify the document's pres context, so that the style changes * method will notify the document's pres context, so that the style changes
* will be noticed. * will be noticed.
*/ */
virtual nsresult SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule, virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
PRBool aNotify) = 0; PRBool aNotify) = 0;
#endif // MOZ_SMIL #endif // MOZ_SMIL

View File

@ -44,7 +44,7 @@
#include "nsAttrValue.h" #include "nsAttrValue.h"
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "mozilla/css/Declaration.h" #include "mozilla/css/Declaration.h"
#include "nsIHTMLDocument.h" #include "nsIHTMLDocument.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -80,7 +80,7 @@ nsAttrValue::nsAttrValue(const nsAString& aValue)
SetTo(aValue); SetTo(aValue);
} }
nsAttrValue::nsAttrValue(nsICSSStyleRule* aValue, const nsAString* aSerialized) nsAttrValue::nsAttrValue(css::StyleRule* aValue, const nsAString* aSerialized)
: mBits(0) : mBits(0)
{ {
SetTo(aValue, aSerialized); SetTo(aValue, aSerialized);
@ -313,7 +313,7 @@ nsAttrValue::SetTo(PRInt16 aInt)
} }
void void
nsAttrValue::SetTo(nsICSSStyleRule* aValue, const nsAString* aSerialized) nsAttrValue::SetTo(css::StyleRule* aValue, const nsAString* aSerialized)
{ {
if (EnsureEmptyMiscContainer()) { if (EnsureEmptyMiscContainer()) {
MiscContainer* cont = GetMiscContainer(); MiscContainer* cont = GetMiscContainer();

View File

@ -55,13 +55,18 @@
typedef PRUptrdiff PtrBits; typedef PRUptrdiff PtrBits;
class nsAString; class nsAString;
class nsIAtom; class nsIAtom;
class nsICSSStyleRule;
class nsISVGValue; class nsISVGValue;
class nsIDocument; class nsIDocument;
template<class E, class A> class nsTArray; template<class E, class A> class nsTArray;
template<class E, class A> class nsTPtrArray; template<class E, class A> class nsTPtrArray;
struct nsTArrayDefaultAllocator; struct nsTArrayDefaultAllocator;
namespace mozilla {
namespace css {
class StyleRule;
}
}
#define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12 #define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12
#define NS_ATTRVALUE_BASETYPE_MASK (PtrBits(3)) #define NS_ATTRVALUE_BASETYPE_MASK (PtrBits(3))
@ -99,7 +104,7 @@ public:
nsAttrValue(); nsAttrValue();
nsAttrValue(const nsAttrValue& aOther); nsAttrValue(const nsAttrValue& aOther);
explicit nsAttrValue(const nsAString& aValue); explicit nsAttrValue(const nsAString& aValue);
nsAttrValue(nsICSSStyleRule* aValue, const nsAString* aSerialized); nsAttrValue(mozilla::css::StyleRule* aValue, const nsAString* aSerialized);
#ifdef MOZ_SVG #ifdef MOZ_SVG
explicit nsAttrValue(nsISVGValue* aValue); explicit nsAttrValue(nsISVGValue* aValue);
#endif #endif
@ -136,7 +141,7 @@ public:
void SetTo(const nsAttrValue& aOther); void SetTo(const nsAttrValue& aOther);
void SetTo(const nsAString& aValue); void SetTo(const nsAString& aValue);
void SetTo(PRInt16 aInt); void SetTo(PRInt16 aInt);
void SetTo(nsICSSStyleRule* aValue, const nsAString* aSerialized); void SetTo(mozilla::css::StyleRule* aValue, const nsAString* aSerialized);
#ifdef MOZ_SVG #ifdef MOZ_SVG
void SetTo(nsISVGValue* aValue); void SetTo(nsISVGValue* aValue);
#endif #endif
@ -156,7 +161,7 @@ public:
inline PRInt16 GetEnumValue() const; inline PRInt16 GetEnumValue() const;
inline float GetPercentValue() const; inline float GetPercentValue() const;
inline AtomArray* GetAtomArrayValue() const; inline AtomArray* GetAtomArrayValue() const;
inline nsICSSStyleRule* GetCSSStyleRuleValue() const; inline mozilla::css::StyleRule* GetCSSStyleRuleValue() const;
#ifdef MOZ_SVG #ifdef MOZ_SVG
inline nsISVGValue* GetSVGValue() const; inline nsISVGValue* GetSVGValue() const;
#endif #endif
@ -336,7 +341,7 @@ private:
nscolor mColor; nscolor mColor;
PRUint32 mEnumValue; PRUint32 mEnumValue;
PRInt32 mPercent; PRInt32 mPercent;
nsICSSStyleRule* mCSSStyleRule; mozilla::css::StyleRule* mCSSStyleRule;
AtomArray* mAtomArray; AtomArray* mAtomArray;
#ifdef MOZ_SVG #ifdef MOZ_SVG
nsISVGValue* mSVGValue; nsISVGValue* mSVGValue;
@ -437,7 +442,7 @@ nsAttrValue::GetAtomArrayValue() const
return GetMiscContainer()->mAtomArray; return GetMiscContainer()->mAtomArray;
} }
inline nsICSSStyleRule* inline mozilla::css::StyleRule*
nsAttrValue::GetCSSStyleRuleValue() const nsAttrValue::GetCSSStyleRuleValue() const
{ {
NS_PRECONDITION(Type() == eCSSStyleRule, "wrong type"); NS_PRECONDITION(Type() == eCSSStyleRule, "wrong type");

View File

@ -67,6 +67,8 @@
#include "pldhash.h" #include "pldhash.h"
#include "prprf.h" #include "prprf.h"
namespace css = mozilla::css;
nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<nsINodeInfo> aNodeInfo) nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsIContent(aNodeInfo) : nsIContent(aNodeInfo)
{ {
@ -1120,14 +1122,14 @@ nsGenericDOMDataNode::GetSMILOverrideStyle(nsIDOMCSSStyleDeclaration** aStyle)
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
nsICSSStyleRule* css::StyleRule*
nsGenericDOMDataNode::GetSMILOverrideStyleRule() nsGenericDOMDataNode::GetSMILOverrideStyleRule()
{ {
return nsnull; return nsnull;
} }
nsresult nsresult
nsGenericDOMDataNode::SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule, nsGenericDOMDataNode::SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
PRBool aNotify) PRBool aNotify)
{ {
NS_NOTREACHED("How come we're setting SMILOverrideStyle on a non-element?"); NS_NOTREACHED("How come we're setting SMILOverrideStyle on a non-element?");
@ -1135,14 +1137,14 @@ nsGenericDOMDataNode::SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule,
} }
#endif // MOZ_SMIL #endif // MOZ_SMIL
nsICSSStyleRule* css::StyleRule*
nsGenericDOMDataNode::GetInlineStyleRule() nsGenericDOMDataNode::GetInlineStyleRule()
{ {
return nsnull; return nsnull;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsGenericDOMDataNode::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, nsGenericDOMDataNode::SetInlineStyleRule(css::StyleRule* aStyleRule,
PRBool aNotify) PRBool aNotify)
{ {
NS_NOTREACHED("How come we're setting inline style on a non-element?"); NS_NOTREACHED("How come we're setting inline style on a non-element?");

View File

@ -235,8 +235,8 @@ public:
return nsnull; return nsnull;
} }
virtual nsresult GetSMILOverrideStyle(nsIDOMCSSStyleDeclaration** aStyle); virtual nsresult GetSMILOverrideStyle(nsIDOMCSSStyleDeclaration** aStyle);
virtual nsICSSStyleRule* GetSMILOverrideStyleRule(); virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule();
virtual nsresult SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule, virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
PRBool aNotify); PRBool aNotify);
#endif // MOZ_SMIL #endif // MOZ_SMIL
@ -252,8 +252,8 @@ public:
virtual nsIAtom* DoGetID() const; virtual nsIAtom* DoGetID() const;
virtual const nsAttrValue* DoGetClasses() const; virtual const nsAttrValue* DoGetClasses() const;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
virtual nsICSSStyleRule* GetInlineStyleRule(); virtual mozilla::css::StyleRule* GetInlineStyleRule();
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify); NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, PRBool aNotify);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const; PRInt32 aModType) const;

View File

@ -133,7 +133,7 @@
#include "nsIViewManager.h" #include "nsIViewManager.h"
#include "nsIScrollableFrame.h" #include "nsIScrollableFrame.h"
#include "nsXBLInsertionPoint.h" #include "nsXBLInsertionPoint.h"
#include "nsICSSStyleRule.h" /* For nsCSSSelectorList */ #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */
#include "nsCSSRuleProcessor.h" #include "nsCSSRuleProcessor.h"
#include "nsRuleProcessorData.h" #include "nsRuleProcessorData.h"
@ -155,6 +155,7 @@
#endif /* MOZ_SVG */ #endif /* MOZ_SVG */
using namespace mozilla::dom; using namespace mozilla::dom;
namespace css = mozilla::css;
NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID); NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
@ -3368,7 +3369,7 @@ nsGenericElement::GetSMILOverrideStyle(nsIDOMCSSStyleDeclaration** aStyle)
return NS_OK; return NS_OK;
} }
nsICSSStyleRule* css::StyleRule*
nsGenericElement::GetSMILOverrideStyleRule() nsGenericElement::GetSMILOverrideStyleRule()
{ {
nsGenericElement::nsDOMSlots *slots = GetExistingDOMSlots(); nsGenericElement::nsDOMSlots *slots = GetExistingDOMSlots();
@ -3376,7 +3377,7 @@ nsGenericElement::GetSMILOverrideStyleRule()
} }
nsresult nsresult
nsGenericElement::SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule, nsGenericElement::SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
PRBool aNotify) PRBool aNotify)
{ {
nsGenericElement::nsDOMSlots *slots = DOMSlots(); nsGenericElement::nsDOMSlots *slots = DOMSlots();
@ -3400,14 +3401,14 @@ nsGenericElement::SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule,
} }
#endif // MOZ_SMIL #endif // MOZ_SMIL
nsICSSStyleRule* css::StyleRule*
nsGenericElement::GetInlineStyleRule() nsGenericElement::GetInlineStyleRule()
{ {
return nsnull; return nsnull;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsGenericElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, nsGenericElement::SetInlineStyleRule(css::StyleRule* aStyleRule,
PRBool aNotify) PRBool aNotify)
{ {
NS_NOTYETIMPLEMENTED("nsGenericElement::SetInlineStyleRule"); NS_NOTYETIMPLEMENTED("nsGenericElement::SetInlineStyleRule");

View File

@ -456,8 +456,8 @@ public:
return nsnull; return nsnull;
} }
virtual nsresult GetSMILOverrideStyle(nsIDOMCSSStyleDeclaration** aStyle); virtual nsresult GetSMILOverrideStyle(nsIDOMCSSStyleDeclaration** aStyle);
virtual nsICSSStyleRule* GetSMILOverrideStyleRule(); virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule();
virtual nsresult SetSMILOverrideStyleRule(nsICSSStyleRule* aStyleRule, virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
PRBool aNotify); PRBool aNotify);
#endif // MOZ_SMIL #endif // MOZ_SMIL
@ -473,8 +473,8 @@ public:
virtual const nsAttrValue* DoGetClasses() const; virtual const nsAttrValue* DoGetClasses() const;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
virtual nsICSSStyleRule* GetInlineStyleRule(); virtual mozilla::css::StyleRule* GetInlineStyleRule();
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify); NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, PRBool aNotify);
NS_IMETHOD_(PRBool) NS_IMETHOD_(PRBool)
IsAttributeMapped(const nsIAtom* aAttribute) const; IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
@ -961,7 +961,7 @@ public:
/** /**
* Holds any SMIL override style rules for this element. * Holds any SMIL override style rules for this element.
*/ */
nsCOMPtr<nsICSSStyleRule> mSMILOverrideStyleRule; nsRefPtr<mozilla::css::StyleRule> mSMILOverrideStyleRule;
/** /**
* An object implementing nsIDOMNamedNodeMap for this content (attributes) * An object implementing nsIDOMNamedNodeMap for this content (attributes)

View File

@ -47,7 +47,7 @@
#include "nsDOMCSSAttrDeclaration.h" #include "nsDOMCSSAttrDeclaration.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsCSSParser.h" #include "nsCSSParser.h"
#include "mozilla/css/Loader.h" #include "mozilla/css/Loader.h"
#include "nsIDOMMutationEvent.h" #include "nsIDOMMutationEvent.h"
@ -57,6 +57,8 @@
#include "nsIDOMSVGStylable.h" #include "nsIDOMSVGStylable.h"
#endif #endif
namespace css = mozilla::css;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIContent methods // nsIContent methods
@ -157,7 +159,7 @@ nsStyledElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aAttribute,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsStyledElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify) nsStyledElement::SetInlineStyleRule(css::StyleRule* aStyleRule, PRBool aNotify)
{ {
SetFlags(NODE_MAY_HAVE_STYLE); SetFlags(NODE_MAY_HAVE_STYLE);
PRBool modification = PR_FALSE; PRBool modification = PR_FALSE;
@ -195,7 +197,7 @@ nsStyledElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify)
aNotify, nsnull); aNotify, nsnull);
} }
nsICSSStyleRule* css::StyleRule*
nsStyledElement::GetInlineStyleRule() nsStyledElement::GetInlineStyleRule()
{ {
if (!HasFlag(NODE_MAY_HAVE_STYLE)) { if (!HasFlag(NODE_MAY_HAVE_STYLE)) {
@ -320,12 +322,12 @@ nsStyledElement::ParseStyleAttribute(const nsAString& aValue,
} }
if (isCSS) { if (isCSS) {
mozilla::css::Loader* cssLoader = doc->CSSLoader(); css::Loader* cssLoader = doc->CSSLoader();
nsCSSParser cssParser(cssLoader); nsCSSParser cssParser(cssLoader);
if (cssParser) { if (cssParser) {
nsCOMPtr<nsIURI> baseURI = GetBaseURI(); nsCOMPtr<nsIURI> baseURI = GetBaseURI();
nsCOMPtr<nsICSSStyleRule> rule; nsRefPtr<css::StyleRule> rule;
cssParser.ParseStyleAttribute(aValue, doc->GetDocumentURI(), cssParser.ParseStyleAttribute(aValue, doc->GetDocumentURI(),
baseURI, baseURI,
NodePrincipal(), NodePrincipal(),

View File

@ -49,7 +49,11 @@
#include "nsString.h" #include "nsString.h"
#include "nsGenericElement.h" #include "nsGenericElement.h"
class nsICSSStyleRule; namespace mozilla {
namespace css {
class StyleRule;
}
}
typedef nsGenericElement nsStyledElementBase; typedef nsGenericElement nsStyledElementBase;
@ -70,8 +74,8 @@ public:
virtual nsIAtom* DoGetID() const; virtual nsIAtom* DoGetID() const;
virtual const nsAttrValue* DoGetClasses() const; virtual const nsAttrValue* DoGetClasses() const;
virtual nsICSSStyleRule* GetInlineStyleRule(); virtual mozilla::css::StyleRule* GetInlineStyleRule();
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify); NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, PRBool aNotify);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent, nsIContent* aBindingParent,

View File

@ -74,7 +74,7 @@
#include "nsIScriptError.h" #include "nsIScriptError.h"
#include "nsCSSParser.h" #include "nsCSSParser.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "mozilla/css/Declaration.h" #include "mozilla/css/Declaration.h"
#include "nsComputedDOMStyle.h" #include "nsComputedDOMStyle.h"
#include "nsStyleSet.h" #include "nsStyleSet.h"
@ -2175,9 +2175,9 @@ nsCanvasRenderingContext2D::Rect(float x, float y, float w, float h)
static nsresult static nsresult
CreateFontStyleRule(const nsAString& aFont, CreateFontStyleRule(const nsAString& aFont,
nsINode* aNode, nsINode* aNode,
nsICSSStyleRule** aResult) css::StyleRule** aResult)
{ {
nsCOMPtr<nsICSSStyleRule> rule; nsRefPtr<css::StyleRule> rule;
PRBool changed; PRBool changed;
nsIPrincipal* principal = aNode->NodePrincipal(); nsIPrincipal* principal = aNode->NodePrincipal();
@ -2241,7 +2241,7 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
nsCOMArray<nsIStyleRule> rules; nsCOMArray<nsIStyleRule> rules;
nsCOMPtr<nsICSSStyleRule> rule; nsRefPtr<css::StyleRule> rule;
rv = CreateFontStyleRule(font, document, getter_AddRefs(rule)); rv = CreateFontStyleRule(font, document, getter_AddRefs(rule));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
@ -2278,7 +2278,7 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
presShell); presShell);
} else { } else {
// otherwise inherit from default (10px sans-serif) // otherwise inherit from default (10px sans-serif)
nsCOMPtr<nsICSSStyleRule> parentRule; nsRefPtr<css::StyleRule> parentRule;
rv = CreateFontStyleRule(NS_LITERAL_STRING("10px sans-serif"), rv = CreateFontStyleRule(NS_LITERAL_STRING("10px sans-serif"),
document, document,
getter_AddRefs(parentRule)); getter_AddRefs(parentRule));

View File

@ -41,7 +41,7 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIAtom.h" #include "nsIAtom.h"
#include "nsIContentViewer.h" #include "nsIContentViewer.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsCSSStruct.h" #include "nsCSSStruct.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDocumentEncoder.h" #include "nsIDocumentEncoder.h"
@ -320,7 +320,7 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst) const
// to reparse the string into style data until the node is // to reparse the string into style data until the node is
// inserted into the document. Clone the nsICSSRule instead. // inserted into the document. Clone the nsICSSRule instead.
nsCOMPtr<nsICSSRule> ruleClone = value->GetCSSStyleRuleValue()->Clone(); nsCOMPtr<nsICSSRule> ruleClone = value->GetCSSStyleRuleValue()->Clone();
nsCOMPtr<nsICSSStyleRule> styleRule = do_QueryInterface(ruleClone); nsRefPtr<mozilla::css::StyleRule> styleRule = do_QueryObject(ruleClone);
NS_ENSURE_TRUE(styleRule, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(styleRule, NS_ERROR_UNEXPECTED);
rv = aDst->SetInlineStyleRule(styleRule, PR_FALSE); rv = aDst->SetInlineStyleRule(styleRule, PR_FALSE);

View File

@ -70,7 +70,7 @@
#include "nsCSSParser.h" #include "nsCSSParser.h"
#include "nsCSSProperty.h" #include "nsCSSProperty.h"
#include "mozilla/css/Declaration.h" #include "mozilla/css/Declaration.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsUnicharInputStream.h" #include "nsUnicharInputStream.h"
#include "nsCSSStyleSheet.h" #include "nsCSSStyleSheet.h"
#include "nsICSSRuleList.h" #include "nsICSSRuleList.h"
@ -815,7 +815,7 @@ protected:
nsIAtom **aResult); nsIAtom **aResult);
// The return value will be true if we have sanitized the rule // The return value will be true if we have sanitized the rule
PRBool SanitizeStyleRule(nsICSSStyleRule *aRule, nsAutoString &aRuleText); PRBool SanitizeStyleRule(css::StyleRule *aRule, nsAutoString &aRuleText);
PRPackedBool mSkip; // used when we descend into <style> or <script> PRPackedBool mSkip; // used when we descend into <style> or <script>
PRPackedBool mProcessStyle; // used when style is explicitly white-listed PRPackedBool mProcessStyle; // used when style is explicitly white-listed
@ -1050,7 +1050,7 @@ nsHTMLParanoidFragmentSink::AddAttributes(const nsIParserNode& aNode,
// Pass the CSS Loader object to the parser, to allow parser error reports // Pass the CSS Loader object to the parser, to allow parser error reports
// to include the outer window ID. // to include the outer window ID.
nsCSSParser parser(mTargetDocument->CSSLoader()); nsCSSParser parser(mTargetDocument->CSSLoader());
nsCOMPtr<nsICSSStyleRule> rule; nsRefPtr<css::StyleRule> rule;
rv = parser.ParseStyleAttribute(aNode.GetValueAt(i), rv = parser.ParseStyleAttribute(aNode.GetValueAt(i),
mTargetDocument->GetDocumentURI(), mTargetDocument->GetDocumentURI(),
baseURI, baseURI,
@ -1213,7 +1213,7 @@ nsHTMLParanoidFragmentSink::CloseContainer(const nsHTMLTag aTag)
case nsICSSRule::STYLE_RULE: { case nsICSSRule::STYLE_RULE: {
// For style rules, we will just look for and remove the // For style rules, we will just look for and remove the
// -moz-binding properties. // -moz-binding properties.
nsCOMPtr<nsICSSStyleRule> styleRule = do_QueryInterface(rule); nsRefPtr<css::StyleRule> styleRule = do_QueryObject(rule);
NS_ASSERTION(styleRule, "Must be a style rule"); NS_ASSERTION(styleRule, "Must be a style rule");
nsAutoString decl; nsAutoString decl;
didSanitize = SanitizeStyleRule(styleRule, decl) || didSanitize; didSanitize = SanitizeStyleRule(styleRule, decl) || didSanitize;
@ -1239,7 +1239,7 @@ nsHTMLParanoidFragmentSink::CloseContainer(const nsHTMLTag aTag)
} }
PRBool PRBool
nsHTMLParanoidFragmentSink::SanitizeStyleRule(nsICSSStyleRule *aRule, nsAutoString &aRuleText) nsHTMLParanoidFragmentSink::SanitizeStyleRule(css::StyleRule *aRule, nsAutoString &aRuleText)
{ {
PRBool didSanitize = PR_FALSE; PRBool didSanitize = PR_FALSE;
aRuleText.Truncate(); aRuleText.Truncate();

View File

@ -56,7 +56,7 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIXBLService.h" #include "nsIXBLService.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsRuleWalker.h" #include "nsRuleWalker.h"
#include "mozilla/css/Declaration.h" #include "mozilla/css/Declaration.h"
#include "nsCSSProps.h" #include "nsCSSProps.h"
@ -870,7 +870,7 @@ nsSVGElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
} else { } else {
// Ok, this is an animation restyle -- go ahead and update/walk the // Ok, this is an animation restyle -- go ahead and update/walk the
// animated content style rule. // animated content style rule.
nsICSSStyleRule* animContentStyleRule = GetAnimatedContentStyleRule(); css::StyleRule* animContentStyleRule = GetAnimatedContentStyleRule();
if (!animContentStyleRule) { if (!animContentStyleRule) {
UpdateAnimatedContentStyleRule(); UpdateAnimatedContentStyleRule();
animContentStyleRule = GetAnimatedContentStyleRule(); animContentStyleRule = GetAnimatedContentStyleRule();
@ -1183,9 +1183,9 @@ public:
nsAString& aMappedAttrValue); nsAString& aMappedAttrValue);
// If we've parsed any values for mapped attributes, this method returns // If we've parsed any values for mapped attributes, this method returns
// a new already_AddRefed nsICSSStyleRule that incorporates the parsed // a new already_AddRefed css::StyleRule that incorporates the parsed
// values. Otherwise, this method returns null. // values. Otherwise, this method returns null.
already_AddRefed<nsICSSStyleRule> CreateStyleRule(); already_AddRefed<css::StyleRule> CreateStyleRule();
private: private:
// MEMBER DATA // MEMBER DATA
@ -1246,14 +1246,14 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
mNodePrincipal, mDecl, &changed, PR_FALSE); mNodePrincipal, mDecl, &changed, PR_FALSE);
} }
already_AddRefed<nsICSSStyleRule> already_AddRefed<css::StyleRule>
MappedAttrParser::CreateStyleRule() MappedAttrParser::CreateStyleRule()
{ {
if (!mDecl) { if (!mDecl) {
return nsnull; // No mapped attributes were parsed return nsnull; // No mapped attributes were parsed
} }
nsCOMPtr<nsICSSStyleRule> rule = NS_NewCSSStyleRule(nsnull, mDecl); nsRefPtr<css::StyleRule> rule = NS_NewCSSStyleRule(nsnull, mDecl);
mDecl = nsnull; // We no longer own the declaration -- drop our pointer to it mDecl = nsnull; // We no longer own the declaration -- drop our pointer to it
return rule.forget(); return rule.forget();
} }
@ -1333,7 +1333,7 @@ ReleaseStyleRule(void* aObject, /* unused */
NS_ABORT_IF_FALSE(aPropertyName == SMIL_MAPPED_ATTR_STYLERULE_ATOM, NS_ABORT_IF_FALSE(aPropertyName == SMIL_MAPPED_ATTR_STYLERULE_ATOM,
"unexpected property name, for " "unexpected property name, for "
"animated content style rule"); "animated content style rule");
nsICSSStyleRule* styleRule = static_cast<nsICSSStyleRule*>(aPropertyValue); css::StyleRule* styleRule = static_cast<css::StyleRule*>(aPropertyValue);
NS_ABORT_IF_FALSE(styleRule, "unexpected null style rule"); NS_ABORT_IF_FALSE(styleRule, "unexpected null style rule");
styleRule->Release(); styleRule->Release();
} }
@ -1355,7 +1355,7 @@ nsSVGElement::UpdateAnimatedContentStyleRule()
doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)-> doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)->
Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser); Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser);
nsRefPtr<nsICSSStyleRule> nsRefPtr<css::StyleRule>
animContentStyleRule(mappedAttrParser.CreateStyleRule()); animContentStyleRule(mappedAttrParser.CreateStyleRule());
if (animContentStyleRule) { if (animContentStyleRule) {
@ -1372,13 +1372,13 @@ nsSVGElement::UpdateAnimatedContentStyleRule()
} }
} }
nsICSSStyleRule* css::StyleRule*
nsSVGElement::GetAnimatedContentStyleRule() nsSVGElement::GetAnimatedContentStyleRule()
{ {
return return
static_cast<nsICSSStyleRule*>(GetProperty(SMIL_MAPPED_ATTR_ANIMVAL, static_cast<css::StyleRule*>(GetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
SMIL_MAPPED_ATTR_STYLERULE_ATOM, SMIL_MAPPED_ATTR_STYLERULE_ATOM,
nsnull)); nsnull));
} }
#endif // MOZ_SMIL #endif // MOZ_SMIL

View File

@ -52,7 +52,6 @@
#include "nsISVGValue.h" #include "nsISVGValue.h"
#include "nsISVGValueObserver.h" #include "nsISVGValueObserver.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsICSSStyleRule.h"
#ifdef MOZ_SMIL #ifdef MOZ_SMIL
#include "nsISMILAttr.h" #include "nsISMILAttr.h"
@ -254,7 +253,7 @@ protected:
void UpdateContentStyleRule(); void UpdateContentStyleRule();
#ifdef MOZ_SMIL #ifdef MOZ_SMIL
void UpdateAnimatedContentStyleRule(); void UpdateAnimatedContentStyleRule();
nsICSSStyleRule* GetAnimatedContentStyleRule(); mozilla::css::StyleRule* GetAnimatedContentStyleRule();
#endif // MOZ_SMIL #endif // MOZ_SMIL
nsISVGValue* GetMappedAttribute(PRInt32 aNamespaceID, nsIAtom* aName); nsISVGValue* GetMappedAttribute(PRInt32 aNamespaceID, nsIAtom* aName);
@ -497,7 +496,7 @@ private:
GetModificationDataForObservable(nsISVGValue* aObservable, GetModificationDataForObservable(nsISVGValue* aObservable,
nsISVGValue::modificationType aModType); nsISVGValue::modificationType aModType);
nsCOMPtr<nsICSSStyleRule> mContentStyleRule; nsRefPtr<mozilla::css::StyleRule> mContentStyleRule;
nsAttrAndChildArray mMappedAttributes; nsAttrAndChildArray mMappedAttributes;
PRPackedBool mSuppressNotification; PRPackedBool mSuppressNotification;

View File

@ -100,7 +100,7 @@
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptGlobalObjectOwner.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsIStyleSheet.h" #include "nsIStyleSheet.h"
#include "nsIURL.h" #include "nsIURL.h"
#include "nsIViewManager.h" #include "nsIViewManager.h"
@ -153,6 +153,8 @@
#include "nsIDOMNSEvent.h" #include "nsIDOMNSEvent.h"
#include "nsCCUncollectableMarker.h" #include "nsCCUncollectableMarker.h"
namespace css = mozilla::css;
// Global object maintenance // Global object maintenance
nsIXBLService * nsXULElement::gXBLService = nsnull; nsIXBLService * nsXULElement::gXBLService = nsnull;
@ -1804,7 +1806,7 @@ nsXULElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
return NS_OK; return NS_OK;
} }
nsICSSStyleRule* css::StyleRule*
nsXULElement::GetInlineStyleRule() nsXULElement::GetInlineStyleRule()
{ {
if (!HasFlag(NODE_MAY_HAVE_STYLE)) { if (!HasFlag(NODE_MAY_HAVE_STYLE)) {
@ -1969,7 +1971,7 @@ nsXULElement::EnsureLocalStyle()
protoattr->mValue.ToString(stringValue); protoattr->mValue.ToString(stringValue);
nsAttrValue value; nsAttrValue value;
nsCOMPtr<nsICSSStyleRule> styleRule = do_QueryInterface(ruleClone); nsRefPtr<css::StyleRule> styleRule = do_QueryObject(ruleClone);
value.SetTo(styleRule, &stringValue); value.SetTo(styleRule, &stringValue);
nsresult rv = nsresult rv =
@ -2347,7 +2349,7 @@ nsresult nsXULElement::MakeHeavyweight()
nsString stringValue; nsString stringValue;
protoattr->mValue.ToString(stringValue); protoattr->mValue.ToString(stringValue);
nsCOMPtr<nsICSSStyleRule> styleRule = do_QueryInterface(ruleClone); nsRefPtr<css::StyleRule> styleRule = do_QueryObject(ruleClone);
attrValue.SetTo(styleRule, &stringValue); attrValue.SetTo(styleRule, &stringValue);
} }
else { else {
@ -2878,7 +2880,7 @@ nsXULPrototypeElement::SetAttrAt(PRUint32 aPos, const nsAString& aValue,
else if (mAttributes[aPos].mName.Equals(nsGkAtoms::style)) { else if (mAttributes[aPos].mName.Equals(nsGkAtoms::style)) {
mHasStyleAttribute = PR_TRUE; mHasStyleAttribute = PR_TRUE;
// Parse the element's 'style' attribute // Parse the element's 'style' attribute
nsCOMPtr<nsICSSStyleRule> rule; nsRefPtr<css::StyleRule> rule;
nsCSSParser parser; nsCSSParser parser;
NS_ENSURE_TRUE(parser, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(parser, NS_ERROR_OUT_OF_MEMORY);

View File

@ -80,7 +80,6 @@
class nsIDocument; class nsIDocument;
class nsString; class nsString;
class nsIDocShell; class nsIDocShell;
class nsICSSStyleRule;
class nsIObjectInputStream; class nsIObjectInputStream;
class nsIObjectOutputStream; class nsIObjectOutputStream;
@ -88,6 +87,12 @@ class nsIScriptGlobalObjectOwner;
class nsXULPrototypeNode; class nsXULPrototypeNode;
typedef nsTArray<nsRefPtr<nsXULPrototypeNode> > nsPrototypeArray; typedef nsTArray<nsRefPtr<nsXULPrototypeNode> > nsPrototypeArray;
namespace mozilla {
namespace css {
class StyleRule;
}
}
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID); static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -540,7 +545,7 @@ public:
virtual const nsAttrValue* DoGetClasses() const; virtual const nsAttrValue* DoGetClasses() const;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
virtual nsICSSStyleRule* GetInlineStyleRule(); virtual mozilla::css::StyleRule* GetInlineStyleRule();
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const; PRInt32 aModType) const;
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;

View File

@ -2276,7 +2276,7 @@ nsresult PresShell::CreatePreferenceStyleSheet(void)
} }
// XXX We want these after the @namespace rule. Does order matter // XXX We want these after the @namespace rule. Does order matter
// for these rules, or can we call nsICSSStyleRule::StyleRuleCount() // for these rules, or can we call StyleRule::StyleRuleCount()
// and just "append"? // and just "append"?
static PRUint32 sInsertPrefSheetRulesAt = 1; static PRUint32 sInsertPrefSheetRulesAt = 1;

View File

@ -48,7 +48,7 @@
#include "nsIDOMCharacterData.h" #include "nsIDOMCharacterData.h"
#include "nsRuleNode.h" #include "nsRuleNode.h"
#include "nsIStyleRule.h" #include "nsIStyleRule.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsICSSStyleRuleDOMWrapper.h" #include "nsICSSStyleRuleDOMWrapper.h"
#include "nsIDOMWindowInternal.h" #include "nsIDOMWindowInternal.h"
#include "nsXBLBinding.h" #include "nsXBLBinding.h"
@ -170,10 +170,10 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
NS_NewISupportsArray(getter_AddRefs(rules)); NS_NewISupportsArray(getter_AddRefs(rules));
if (!rules) return NS_ERROR_OUT_OF_MEMORY; if (!rules) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsICSSStyleRule> cssRule; nsRefPtr<mozilla::css::StyleRule> cssRule;
nsCOMPtr<nsIDOMCSSRule> domRule; nsCOMPtr<nsIDOMCSSRule> domRule;
for ( ; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) { for ( ; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) {
cssRule = do_QueryInterface(ruleNode->GetRule()); cssRule = do_QueryObject(ruleNode->GetRule());
if (cssRule) { if (cssRule) {
cssRule->GetDOMRule(getter_AddRefs(domRule)); cssRule->GetDOMRule(getter_AddRefs(domRule));
if (domRule) if (domRule)
@ -195,7 +195,7 @@ inDOMUtils::GetRuleLine(nsIDOMCSSStyleRule *aRule, PRUint32 *_retval)
NS_ENSURE_ARG_POINTER(aRule); NS_ENSURE_ARG_POINTER(aRule);
nsCOMPtr<nsICSSStyleRuleDOMWrapper> rule = do_QueryInterface(aRule); nsCOMPtr<nsICSSStyleRuleDOMWrapper> rule = do_QueryInterface(aRule);
nsCOMPtr<nsICSSStyleRule> cssrule; nsRefPtr<mozilla::css::StyleRule> cssrule;
nsresult rv = rule->GetCSSStyleRule(getter_AddRefs(cssrule)); nsresult rv = rule->GetCSSStyleRule(getter_AddRefs(cssrule));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(cssrule != nsnull, NS_ERROR_FAILURE); NS_ENSURE_TRUE(cssrule != nsnull, NS_ERROR_FAILURE);

View File

@ -47,7 +47,6 @@
#include "nsIStyleSheet.h" #include "nsIStyleSheet.h"
#include "nsIDOMCSSStyleSheet.h" #include "nsIDOMCSSStyleSheet.h"
#include "nsICSSRule.h" #include "nsICSSRule.h"
#include "nsICSSStyleRule.h"
#include "nsStyleChangeList.h" #include "nsStyleChangeList.h"
#include "nsFrameManager.h" #include "nsFrameManager.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"

View File

@ -80,7 +80,6 @@ EXPORTS = \
nsICSSPseudoComparator.h \ nsICSSPseudoComparator.h \
nsICSSRule.h \ nsICSSRule.h \
nsICSSRuleList.h \ nsICSSRuleList.h \
nsICSSStyleRule.h \
nsICSSStyleRuleDOMWrapper.h \ nsICSSStyleRuleDOMWrapper.h \
nsIStyleRule.h \ nsIStyleRule.h \
nsIStyleRuleProcessor.h \ nsIStyleRuleProcessor.h \
@ -104,6 +103,7 @@ EXPORTS = \
EXPORTS_mozilla/css = \ EXPORTS_mozilla/css = \
Declaration.h \ Declaration.h \
Loader.h \ Loader.h \
StyleRule.h \
$(NULL) $(NULL)
CPPSRCS = \ CPPSRCS = \
@ -120,7 +120,6 @@ CPPSRCS = \
nsCSSRules.cpp \ nsCSSRules.cpp \
nsCSSScanner.cpp \ nsCSSScanner.cpp \
nsCSSStruct.cpp \ nsCSSStruct.cpp \
nsCSSStyleRule.cpp \
nsCSSStyleSheet.cpp \ nsCSSStyleSheet.cpp \
nsCSSValue.cpp \ nsCSSValue.cpp \
nsComputedDOMStyle.cpp \ nsComputedDOMStyle.cpp \
@ -145,6 +144,7 @@ CPPSRCS = \
nsStyleTransformMatrix.cpp \ nsStyleTransformMatrix.cpp \
nsStyleUtil.cpp \ nsStyleUtil.cpp \
nsTransitionManager.cpp \ nsTransitionManager.cpp \
StyleRule.cpp \
$(NULL) $(NULL)
FORCE_STATIC_LIB = 1 FORCE_STATIC_LIB = 1

View File

@ -44,9 +44,7 @@
* declarations * declarations
*/ */
#include "nsCOMPtr.h" #include "mozilla/css/StyleRule.h"
#include "nsCSSRule.h"
#include "nsICSSStyleRule.h"
#include "nsICSSGroupRule.h" #include "nsICSSGroupRule.h"
#include "mozilla/css/Declaration.h" #include "mozilla/css/Declaration.h"
#include "nsCSSStyleSheet.h" #include "nsCSSStyleSheet.h"
@ -967,7 +965,7 @@ class DOMCSSStyleRule;
class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration
{ {
public: public:
DOMCSSDeclarationImpl(nsICSSStyleRule *aRule); DOMCSSDeclarationImpl(css::StyleRule *aRule);
virtual ~DOMCSSDeclarationImpl(void); virtual ~DOMCSSDeclarationImpl(void);
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent); NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent);
@ -977,7 +975,7 @@ public:
virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI, virtual nsresult GetCSSParsingEnvironment(nsIURI** aSheetURI,
nsIURI** aBaseURI, nsIURI** aBaseURI,
nsIPrincipal** aSheetPrincipal, nsIPrincipal** aSheetPrincipal,
mozilla::css::Loader** aCSSLoader); css::Loader** aCSSLoader);
virtual nsIDocument* DocToUpdate(); virtual nsIDocument* DocToUpdate();
// Override |AddRef| and |Release| for being a member of // Override |AddRef| and |Release| for being a member of
@ -995,7 +993,7 @@ public:
protected: protected:
// This reference is not reference-counted. The rule object tells us // This reference is not reference-counted. The rule object tells us
// when it's about to go away. // when it's about to go away.
nsICSSStyleRule *mRule; css::StyleRule *mRule;
inline css::DOMCSSStyleRule* DomRule(); inline css::DOMCSSStyleRule* DomRule();
@ -1012,7 +1010,7 @@ namespace css {
class DOMCSSStyleRule : public nsICSSStyleRuleDOMWrapper class DOMCSSStyleRule : public nsICSSStyleRuleDOMWrapper
{ {
public: public:
DOMCSSStyleRule(nsICSSStyleRule *aRule); DOMCSSStyleRule(StyleRule *aRule);
virtual ~DOMCSSStyleRule(); virtual ~DOMCSSStyleRule();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -1020,7 +1018,7 @@ public:
NS_DECL_NSIDOMCSSSTYLERULE NS_DECL_NSIDOMCSSSTYLERULE
// nsICSSStyleRuleDOMWrapper // nsICSSStyleRuleDOMWrapper
NS_IMETHOD GetCSSStyleRule(nsICSSStyleRule **aResult); NS_IMETHOD GetCSSStyleRule(StyleRule **aResult);
DOMCSSDeclarationImpl* DOMDeclaration() { return &mDOMDeclaration; } DOMCSSDeclarationImpl* DOMDeclaration() { return &mDOMDeclaration; }
@ -1029,7 +1027,7 @@ public:
protected: protected:
DOMCSSDeclarationImpl mDOMDeclaration; DOMCSSDeclarationImpl mDOMDeclaration;
nsICSSStyleRule* Rule() { StyleRule* Rule() {
return mDOMDeclaration.mRule; return mDOMDeclaration.mRule;
} }
}; };
@ -1037,7 +1035,7 @@ protected:
} // namespace css } // namespace css
} // namespace mozilla } // namespace mozilla
DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(nsICSSStyleRule *aRule) DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(css::StyleRule *aRule)
: mRule(aRule) : mRule(aRule)
{ {
MOZ_COUNT_CTOR(DOMCSSDeclarationImpl); MOZ_COUNT_CTOR(DOMCSSDeclarationImpl);
@ -1085,7 +1083,7 @@ nsresult
DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI, DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI,
nsIURI** aBaseURI, nsIURI** aBaseURI,
nsIPrincipal** aSheetPrincipal, nsIPrincipal** aSheetPrincipal,
mozilla::css::Loader** aCSSLoader) css::Loader** aCSSLoader)
{ {
// null out the out params since some of them may not get initialized below // null out the out params since some of them may not get initialized below
*aSheetURI = nsnull; *aSheetURI = nsnull;
@ -1148,7 +1146,7 @@ DOMCSSDeclarationImpl::SetCSSDeclaration(css::Declaration* aDecl)
mozAutoDocUpdate updateBatch(owningDoc, UPDATE_STYLE, PR_TRUE); mozAutoDocUpdate updateBatch(owningDoc, UPDATE_STYLE, PR_TRUE);
nsCOMPtr<nsICSSStyleRule> oldRule = mRule; nsRefPtr<css::StyleRule> oldRule = mRule;
mRule = oldRule->DeclarationChanged(aDecl, PR_TRUE).get(); mRule = oldRule->DeclarationChanged(aDecl, PR_TRUE).get();
if (!mRule) if (!mRule)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -1177,7 +1175,7 @@ DOMCI_DATA(CSSStyleRule, css::DOMCSSStyleRule)
namespace mozilla { namespace mozilla {
namespace css { namespace css {
DOMCSSStyleRule::DOMCSSStyleRule(nsICSSStyleRule* aRule) DOMCSSStyleRule::DOMCSSStyleRule(StyleRule* aRule)
: mDOMDeclaration(aRule) : mDOMDeclaration(aRule)
{ {
} }
@ -1281,7 +1279,7 @@ DOMCSSStyleRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
} }
NS_IMETHODIMP NS_IMETHODIMP
DOMCSSStyleRule::GetCSSStyleRule(nsICSSStyleRule **aResult) DOMCSSStyleRule::GetCSSStyleRule(StyleRule **aResult)
{ {
*aResult = Rule(); *aResult = Rule();
NS_IF_ADDREF(*aResult); NS_IF_ADDREF(*aResult);
@ -1296,76 +1294,6 @@ DOMCSSStyleRule::GetCSSStyleRule(nsICSSStyleRule **aResult)
namespace mozilla { namespace mozilla {
namespace css { namespace css {
class NS_FINAL_CLASS StyleRule : public nsCSSRule,
public nsICSSStyleRule
{
public:
StyleRule(nsCSSSelectorList* aSelector,
Declaration *aDeclaration);
private:
// for |Clone|
StyleRule(const StyleRule& aCopy);
// for |DeclarationChanged|
StyleRule(StyleRule& aCopy,
Declaration *aDeclaration);
public:
NS_DECL_ISUPPORTS
virtual nsCSSSelectorList* Selector(void);
virtual PRUint32 GetLineNumber(void) const;
virtual void SetLineNumber(PRUint32 aLineNumber);
virtual Declaration* GetDeclaration(void) const;
virtual nsIStyleRule* GetImportantRule(void);
virtual void RuleMatched();
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
virtual void SetParentRule(nsICSSGroupRule* aRule);
virtual nsresult GetCssText(nsAString& aCssText);
virtual nsresult SetCssText(const nsAString& aCssText);
virtual nsresult GetParentStyleSheet(nsCSSStyleSheet** aSheet);
virtual nsresult GetParentRule(nsICSSGroupRule** aParentRule);
virtual nsresult GetSelectorText(nsAString& aSelectorText);
virtual nsresult SetSelectorText(const nsAString& aSelectorText);
virtual PRInt32 GetType() const;
virtual already_AddRefed<nsICSSRule> Clone() const;
nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
virtual already_AddRefed<nsICSSStyleRule>
DeclarationChanged(Declaration* aDecl, PRBool aHandleContainer);
// The new mapping function.
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
#ifdef DEBUG
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
#endif
private:
// These are not supported and are not implemented!
StyleRule& operator=(const StyleRule& aCopy);
private:
~StyleRule();
protected:
nsCSSSelectorList* mSelector; // null for style attribute
Declaration* mDeclaration;
ImportantRule* mImportantRule; // initialized by RuleMatched
DOMCSSStyleRule* mDOMRule;
// Keep the same type so that MSVC packs them.
PRUint32 mLineNumber : 31;
PRUint32 mWasMatched : 1;
};
StyleRule::StyleRule(nsCSSSelectorList* aSelector, StyleRule::StyleRule(nsCSSSelectorList* aSelector,
Declaration* aDeclaration) Declaration* aDeclaration)
: nsCSSRule(), : nsCSSRule(),
@ -1432,10 +1360,15 @@ StyleRule::~StyleRule()
// QueryInterface implementation for StyleRule // QueryInterface implementation for StyleRule
NS_INTERFACE_MAP_BEGIN(StyleRule) NS_INTERFACE_MAP_BEGIN(StyleRule)
NS_INTERFACE_MAP_ENTRY(nsICSSStyleRule) if (aIID.Equals(NS_GET_IID(mozilla::css::StyleRule))) {
*aInstancePtr = this;
NS_ADDREF_THIS();
return NS_OK;
}
else
NS_INTERFACE_MAP_ENTRY(nsICSSRule) NS_INTERFACE_MAP_ENTRY(nsICSSRule)
NS_INTERFACE_MAP_ENTRY(nsIStyleRule) NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSStyleRule) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(StyleRule) NS_IMPL_ADDREF(StyleRule)
@ -1532,7 +1465,7 @@ StyleRule::GetDOMRuleWeak(nsresult *aResult)
return mDOMRule; return mDOMRule;
} }
/* virtual */ already_AddRefed<nsICSSStyleRule> /* virtual */ already_AddRefed<StyleRule>
StyleRule::DeclarationChanged(Declaration* aDecl, StyleRule::DeclarationChanged(Declaration* aDecl,
PRBool aHandleContainer) PRBool aHandleContainer)
{ {
@ -1559,7 +1492,7 @@ StyleRule::DeclarationChanged(Declaration* aDecl,
StyleRule::MapRuleInfoInto(nsRuleData* aRuleData) StyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
{ {
NS_ABORT_IF_FALSE(mWasMatched, NS_ABORT_IF_FALSE(mWasMatched,
"somebody forgot to call nsICSSStyleRule::RuleMatched"); "somebody forgot to call css::StyleRule::RuleMatched");
mDeclaration->MapNormalRuleInfoInto(aRuleData); mDeclaration->MapNormalRuleInfoInto(aRuleData);
} }
@ -1651,7 +1584,7 @@ StyleRule::SetSelectorText(const nsAString& aSelectorText)
} // namespace css } // namespace css
} // namespace mozilla } // namespace mozilla
already_AddRefed<nsICSSStyleRule> already_AddRefed<css::StyleRule>
NS_NewCSSStyleRule(nsCSSSelectorList* aSelector, NS_NewCSSStyleRule(nsCSSSelectorList* aSelector,
css::Declaration* aDeclaration) css::Declaration* aDeclaration)
{ {

View File

@ -42,26 +42,22 @@
* selectors * selectors
*/ */
#ifndef nsICSSStyleRule_h___ #ifndef mozilla_css_StyleRule_h__
#define nsICSSStyleRule_h___ #define mozilla_css_StyleRule_h__
//#include <stdio.h> //#include <stdio.h>
#include "nsICSSRule.h" #include "nsICSSRule.h"
#include "nsCSSRule.h"
#include "nsString.h" #include "nsString.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsCSSValue.h"
#include "nsCSSPseudoElements.h" #include "nsCSSPseudoElements.h"
#include "nsCSSPseudoClasses.h" #include "nsCSSPseudoClasses.h"
#include "nsAutoPtr.h"
class nsIAtom; class nsIAtom;
class nsCSSStyleSheet; class nsCSSStyleSheet;
struct nsCSSSelectorList; struct nsCSSSelectorList;
class nsCSSCompressedDataBlock;
namespace mozilla {
namespace css {
class Declaration;
}
}
struct nsAtomList { struct nsAtomList {
public: public:
@ -292,22 +288,41 @@ private:
nsCSSSelectorList& operator=(const nsCSSSelectorList& aCopy); nsCSSSelectorList& operator=(const nsCSSSelectorList& aCopy);
}; };
// 97eb9881-55fb-462c-be1a-b6309d42f8d0 // 464bab7a-2fce-4f30-ab44-b7a5f3aae57d
#define NS_ICSS_STYLE_RULE_IID \ #define NS_CSS_STYLE_RULE_IMPL_CID \
{ 0x97eb9881, 0x55fb, 0x462c, \ { 0x464bab7a, 0x2fce, 0x4f30, \
{ 0xbe, 0x1a, 0xb6, 0x30, 0x9d, 0x42, 0xf8, 0xd0 } } { 0xab, 0x44, 0xb7, 0xa5, 0xf3, 0xaa, 0xe5, 0x7d } }
class nsICSSStyleRule : public nsICSSRule { namespace mozilla {
namespace css {
class Declaration;
class ImportantRule;
class DOMCSSStyleRule;
class NS_FINAL_CLASS StyleRule : public nsCSSRule,
public nsICSSRule {
public:
StyleRule(nsCSSSelectorList* aSelector,
Declaration *aDeclaration);
private:
// for |Clone|
StyleRule(const StyleRule& aCopy);
// for |DeclarationChanged|
StyleRule(StyleRule& aCopy,
Declaration *aDeclaration);
public: public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_STYLE_RULE_IID) NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_RULE_IMPL_CID)
NS_DECL_ISUPPORTS
// null for style attribute // null for style attribute
virtual nsCSSSelectorList* Selector(void) = 0; virtual nsCSSSelectorList* Selector();
virtual PRUint32 GetLineNumber(void) const = 0; virtual PRUint32 GetLineNumber() const;
virtual void SetLineNumber(PRUint32 aLineNumber) = 0; virtual void SetLineNumber(PRUint32 aLineNumber);
virtual mozilla::css::Declaration* GetDeclaration(void) const = 0; virtual Declaration* GetDeclaration() const;
/** /**
* Return a new |nsIStyleRule| instance that replaces the current * Return a new |nsIStyleRule| instance that replaces the current
@ -318,29 +333,66 @@ public:
* |DeclarationChanged| handles replacing the object in the container * |DeclarationChanged| handles replacing the object in the container
* sheet or group rule if |aHandleContainer| is true. * sheet or group rule if |aHandleContainer| is true.
*/ */
virtual already_AddRefed<nsICSSStyleRule> virtual already_AddRefed<StyleRule>
DeclarationChanged(mozilla::css::Declaration* aDecl, DeclarationChanged(Declaration* aDecl, PRBool aHandleContainer);
PRBool aHandleContainer) = 0;
virtual nsIStyleRule* GetImportantRule();
/** /**
* The rule processor must call this method before calling * The rule processor must call this method before calling
* nsRuleWalker::Forward on this rule during rule matching. * nsRuleWalker::Forward on this rule during rule matching.
*/ */
virtual void RuleMatched() = 0; virtual void RuleMatched();
// hooks for DOM rule // hooks for DOM rule
virtual nsresult GetCssText(nsAString& aCssText) = 0; virtual nsresult GetCssText(nsAString& aCssText);
virtual nsresult SetCssText(const nsAString& aCssText) = 0; virtual nsresult SetCssText(const nsAString& aCssText);
virtual nsresult GetParentStyleSheet(nsCSSStyleSheet** aSheet) = 0; virtual nsresult GetParentStyleSheet(nsCSSStyleSheet** aSheet);
virtual nsresult GetParentRule(nsICSSGroupRule** aParentRule) = 0; virtual nsresult GetParentRule(nsICSSGroupRule** aParentRule);
virtual nsresult GetSelectorText(nsAString& aSelectorText) = 0; virtual nsresult GetSelectorText(nsAString& aSelectorText);
virtual nsresult SetSelectorText(const nsAString& aSelectorText) = 0; virtual nsresult SetSelectorText(const nsAString& aSelectorText);
virtual PRInt32 GetType() const;
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
virtual void SetParentRule(nsICSSGroupRule* aRule);
virtual already_AddRefed<nsICSSRule> Clone() const;
nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
// The new mapping function.
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
#ifdef DEBUG
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
#endif
private:
// This is not supported and not implemented!
StyleRule& operator=(const StyleRule& aCopy);
private:
~StyleRule();
private:
nsCSSSelectorList* mSelector; // null for style attribute
Declaration* mDeclaration;
ImportantRule* mImportantRule; // initialized by RuleMatched
DOMCSSStyleRule* mDOMRule;
// Keep the same type so that MSVC packs them.
PRUint32 mLineNumber : 31;
PRUint32 mWasMatched : 1;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSStyleRule, NS_ICSS_STYLE_RULE_IID) } // namespace css
} // namespace mozilla
already_AddRefed<nsICSSStyleRule> NS_DEFINE_STATIC_IID_ACCESSOR(mozilla::css::StyleRule, NS_CSS_STYLE_RULE_IMPL_CID)
already_AddRefed<mozilla::css::StyleRule>
NS_NewCSSStyleRule(nsCSSSelectorList* aSelector, NS_NewCSSStyleRule(nsCSSSelectorList* aSelector,
mozilla::css::Declaration* aDeclaration); mozilla::css::Declaration* aDeclaration);
#endif /* nsICSSStyleRule_h___ */ #endif /* mozilla_css_StyleRule_h__ */

View File

@ -51,7 +51,7 @@
#include "nsCSSKeywords.h" #include "nsCSSKeywords.h"
#include "nsCSSScanner.h" #include "nsCSSScanner.h"
#include "mozilla/css/Loader.h" #include "mozilla/css/Loader.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsICSSImportRule.h" #include "nsICSSImportRule.h"
#include "nsCSSRules.h" #include "nsCSSRules.h"
#include "nsICSSNameSpaceRule.h" #include "nsICSSNameSpaceRule.h"
@ -214,7 +214,7 @@ public:
nsIURI* aDocURL, nsIURI* aDocURL,
nsIURI* aBaseURL, nsIURI* aBaseURL,
nsIPrincipal* aNodePrincipal, nsIPrincipal* aNodePrincipal,
nsICSSStyleRule** aResult); css::StyleRule** aResult);
nsresult ParseDeclarations(const nsAString& aBuffer, nsresult ParseDeclarations(const nsAString& aBuffer,
nsIURI* aSheetURL, nsIURI* aSheetURL,
@ -962,10 +962,10 @@ NonMozillaVendorIdentifier(const nsAString& ident)
nsresult nsresult
CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue, CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
nsIURI* aDocURI, nsIURI* aDocURI,
nsIURI* aBaseURI, nsIURI* aBaseURI,
nsIPrincipal* aNodePrincipal, nsIPrincipal* aNodePrincipal,
nsICSSStyleRule** aResult) css::StyleRule** aResult)
{ {
NS_PRECONDITION(aNodePrincipal, "Must have principal here!"); NS_PRECONDITION(aNodePrincipal, "Must have principal here!");
AssertInitialState(); AssertInitialState();
@ -2460,7 +2460,7 @@ CSSParserImpl::ParseRuleSet(RuleAppendFunc aAppendFunc, void* aData,
// Translate the selector list and declaration block into style data // Translate the selector list and declaration block into style data
nsCOMPtr<nsICSSStyleRule> rule = NS_NewCSSStyleRule(slist, declaration); nsRefPtr<css::StyleRule> rule = NS_NewCSSStyleRule(slist, declaration);
rule->SetLineNumber(linenum); rule->SetLineNumber(linenum);
(*aAppendFunc)(rule, aData); (*aAppendFunc)(rule, aData);
@ -8504,7 +8504,7 @@ nsCSSParser::ParseStyleAttribute(const nsAString& aAttributeValue,
nsIURI* aDocURI, nsIURI* aDocURI,
nsIURI* aBaseURI, nsIURI* aBaseURI,
nsIPrincipal* aNodePrincipal, nsIPrincipal* aNodePrincipal,
nsICSSStyleRule** aResult) css::StyleRule** aResult)
{ {
return static_cast<CSSParserImpl*>(mImpl)-> return static_cast<CSSParserImpl*>(mImpl)->
ParseStyleAttribute(aAttributeValue, aDocURI, aBaseURI, ParseStyleAttribute(aAttributeValue, aDocURI, aBaseURI,

View File

@ -46,7 +46,6 @@
#include "nsCOMArray.h" #include "nsCOMArray.h"
class nsICSSRule; class nsICSSRule;
class nsICSSStyleRule;
class nsCSSStyleSheet; class nsCSSStyleSheet;
class nsIPrincipal; class nsIPrincipal;
class nsIURI; class nsIURI;
@ -58,6 +57,7 @@ namespace mozilla {
namespace css { namespace css {
class Declaration; class Declaration;
class Loader; class Loader;
class StyleRule;
} }
} }
@ -128,7 +128,7 @@ public:
nsIURI* aDocURL, nsIURI* aDocURL,
nsIURI* aBaseURL, nsIURI* aBaseURL,
nsIPrincipal* aNodePrincipal, nsIPrincipal* aNodePrincipal,
nsICSSStyleRule** aResult); mozilla::css::StyleRule** aResult);
// Parse the body of a declaration block. Very similar to // Parse the body of a declaration block. Very similar to
// ParseStyleAttribute, but used under different circumstances. // ParseStyleAttribute, but used under different circumstances.

View File

@ -58,7 +58,7 @@
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsICSSPseudoComparator.h" #include "nsICSSPseudoComparator.h"
#include "nsCSSRuleProcessor.h" #include "nsCSSRuleProcessor.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsICSSGroupRule.h" #include "nsICSSGroupRule.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsPresContext.h" #include "nsPresContext.h"
@ -95,6 +95,7 @@
#include "nsGenericElement.h" #include "nsGenericElement.h"
using namespace mozilla::dom; using namespace mozilla::dom;
namespace css = mozilla::css;
#define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled" #define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
@ -112,10 +113,10 @@ PRUint8 nsCSSRuleProcessor::sWinThemeId = nsILookAndFeel::eWindowsTheme_Generic;
* from that rule's selector list. * from that rule's selector list.
*/ */
struct RuleSelectorPair { struct RuleSelectorPair {
RuleSelectorPair(nsICSSStyleRule* aRule, nsCSSSelector* aSelector) RuleSelectorPair(css::StyleRule* aRule, nsCSSSelector* aSelector)
: mRule(aRule), mSelector(aSelector) {} : mRule(aRule), mSelector(aSelector) {}
nsICSSStyleRule* mRule; css::StyleRule* mRule;
nsCSSSelector* mSelector; // which of |mRule|'s selectors nsCSSSelector* mSelector; // which of |mRule|'s selectors
}; };
@ -590,7 +591,7 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
#endif #endif
static inline static inline
void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector, void ContentEnumFunc(css::StyleRule* aRule, nsCSSSelector* aSelector,
RuleProcessorData* data); RuleProcessorData* data);
void RuleHash::EnumerateAllRules(PRInt32 aNameSpace, nsIAtom* aTag, void RuleHash::EnumerateAllRules(PRInt32 aNameSpace, nsIAtom* aTag,
@ -2347,7 +2348,7 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
} }
static inline static inline
void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector, void ContentEnumFunc(css::StyleRule* aRule, nsCSSSelector* aSelector,
RuleProcessorData* data) RuleProcessorData* data)
{ {
TreeMatchContext treeContext(PR_TRUE, data->mRuleWalker->VisitedHandling()); TreeMatchContext treeContext(PR_TRUE, data->mRuleWalker->VisitedHandling());
@ -2359,14 +2360,6 @@ void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector,
nsCSSSelector *next = aSelector->mNext; nsCSSSelector *next = aSelector->mNext;
if (!next || SelectorMatchesTree(*data, next, treeContext, if (!next || SelectorMatchesTree(*data, next, treeContext,
!nodeContext.mIsRelevantLink)) { !nodeContext.mIsRelevantLink)) {
// for performance, require that every implementation of
// nsICSSStyleRule return the same pointer for nsIStyleRule (why
// would anything multiply inherit nsIStyleRule anyway?)
#ifdef DEBUG
nsCOMPtr<nsIStyleRule> iRule = do_QueryInterface(aRule);
NS_ASSERTION(static_cast<nsIStyleRule*>(aRule) == iRule.get(),
"Please fix QI so this performance optimization is valid");
#endif
aRule->RuleMatched(); aRule->RuleMatched();
data->mRuleWalker->Forward(static_cast<nsIStyleRule*>(aRule)); data->mRuleWalker->Forward(static_cast<nsIStyleRule*>(aRule));
// nsStyleSet will deal with the !important rule // nsStyleSet will deal with the !important rule
@ -2422,14 +2415,6 @@ nsCSSRuleProcessor::RulesMatching(AnonBoxRuleProcessorData* aData)
nsTArray<RuleValue>& rules = entry->mRules; nsTArray<RuleValue>& rules = entry->mRules;
for (RuleValue *value = rules.Elements(), *end = value + rules.Length(); for (RuleValue *value = rules.Elements(), *end = value + rules.Length();
value != end; ++value) { value != end; ++value) {
// for performance, require that every implementation of
// nsICSSStyleRule return the same pointer for nsIStyleRule (why
// would anything multiply inherit nsIStyleRule anyway?)
#ifdef DEBUG
nsCOMPtr<nsIStyleRule> iRule = do_QueryInterface(value->mRule);
NS_ASSERTION(static_cast<nsIStyleRule*>(value->mRule) == iRule.get(),
"Please fix QI so this performance optimization is valid");
#endif
value->mRule->RuleMatched(); value->mRule->RuleMatched();
aData->mRuleWalker->Forward(static_cast<nsIStyleRule*>(value->mRule)); aData->mRuleWalker->Forward(static_cast<nsIStyleRule*>(value->mRule));
} }
@ -2981,7 +2966,7 @@ CascadeRuleEnumFunc(nsICSSRule* aRule, void* aData)
PRInt32 type = aRule->GetType(); PRInt32 type = aRule->GetType();
if (nsICSSRule::STYLE_RULE == type) { if (nsICSSRule::STYLE_RULE == type) {
nsICSSStyleRule* styleRule = (nsICSSStyleRule*)aRule; css::StyleRule* styleRule = static_cast<css::StyleRule*>(aRule);
for (nsCSSSelectorList *sel = styleRule->Selector(); for (nsCSSSelectorList *sel = styleRule->Selector();
sel; sel = sel->mNext) { sel; sel = sel->mNext) {

View File

@ -42,8 +42,8 @@
#include "mozilla/css/Declaration.h" #include "mozilla/css/Declaration.h"
#include "mozilla/css/Loader.h" #include "mozilla/css/Loader.h"
#include "mozilla/css/StyleRule.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "nsICSSStyleRule.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMMutationEvent.h" #include "nsIDOMMutationEvent.h"
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
@ -87,14 +87,14 @@ nsresult
nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl) nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl)
{ {
NS_ASSERTION(mElement, "Must have Element to set the declaration!"); NS_ASSERTION(mElement, "Must have Element to set the declaration!");
nsICSSStyleRule* oldRule = css::StyleRule* oldRule =
#ifdef MOZ_SMIL #ifdef MOZ_SMIL
mIsSMILOverride ? mElement->GetSMILOverrideStyleRule() : mIsSMILOverride ? mElement->GetSMILOverrideStyleRule() :
#endif // MOZ_SMIL #endif // MOZ_SMIL
mElement->GetInlineStyleRule(); mElement->GetInlineStyleRule();
NS_ASSERTION(oldRule, "Element must have rule"); NS_ASSERTION(oldRule, "Element must have rule");
nsCOMPtr<nsICSSStyleRule> newRule = nsRefPtr<css::StyleRule> newRule =
oldRule->DeclarationChanged(aDecl, PR_FALSE); oldRule->DeclarationChanged(aDecl, PR_FALSE);
if (!newRule) { if (!newRule) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -134,7 +134,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(PRBool aAllocate)
if (!mElement) if (!mElement)
return nsnull; return nsnull;
nsICSSStyleRule* cssRule; css::StyleRule* cssRule;
#ifdef MOZ_SMIL #ifdef MOZ_SMIL
if (mIsSMILOverride) if (mIsSMILOverride)
cssRule = mElement->GetSMILOverrideStyleRule(); cssRule = mElement->GetSMILOverrideStyleRule();
@ -152,7 +152,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(PRBool aAllocate)
// cannot fail // cannot fail
css::Declaration *decl = new css::Declaration(); css::Declaration *decl = new css::Declaration();
decl->InitializeEmpty(); decl->InitializeEmpty();
nsCOMPtr<nsICSSStyleRule> newRule = NS_NewCSSStyleRule(nsnull, decl); nsRefPtr<css::StyleRule> newRule = NS_NewCSSStyleRule(nsnull, decl);
// this *can* fail (inside SetAttrAndNotify, at least). // this *can* fail (inside SetAttrAndNotify, at least).
nsresult rv; nsresult rv;

View File

@ -47,7 +47,7 @@
#include "nsCSSPseudoElements.h" #include "nsCSSPseudoElements.h"
#include "nsIStyleRule.h" #include "nsIStyleRule.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsIStyleRuleProcessor.h" #include "nsIStyleRuleProcessor.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -58,6 +58,7 @@
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
using namespace mozilla::dom; using namespace mozilla::dom;
namespace css = mozilla::css;
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet() nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
: mDocument(nsnull) : mDocument(nsnull)
@ -74,7 +75,7 @@ nsHTMLCSSStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
Element* element = aData->mElement; Element* element = aData->mElement;
// just get the one and only style rule from the content's STYLE attribute // just get the one and only style rule from the content's STYLE attribute
nsICSSStyleRule* rule = element->GetInlineStyleRule(); css::StyleRule* rule = element->GetInlineStyleRule();
if (rule) { if (rule) {
rule->RuleMatched(); rule->RuleMatched();
aData->mRuleWalker->Forward(rule); aData->mRuleWalker->Forward(rule);

View File

@ -46,15 +46,16 @@
#include "nsIDOMCSSStyleRule.h" #include "nsIDOMCSSStyleRule.h"
// IID for the nsICSSStyleRuleDOMWrapper interface // IID for the nsICSSStyleRuleDOMWrapper interface
// {476a4290-1194-4099-8f2d-a1ccc9bdd676} // {cee1bbb6-0a32-4cf3-8d42-ba3938e9ecaa}
#define NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID \ #define NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID \
{0x476a4290, 0x1194, 0x4099, {0x8f, 0x2d, 0xa1, 0xcc, 0xc9, 0xbd, 0xd6, 0x76}} {0xcee1bbb6, 0x0a32, 0x4cf3, {0x8d, 0x42, 0xba, 0x39, 0x38, 0xe9, 0xec, 0xaa}}
class nsICSSStyleRuleDOMWrapper : public nsIDOMCSSStyleRule { class nsICSSStyleRuleDOMWrapper : public nsIDOMCSSStyleRule {
public: public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID) NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID)
NS_IMETHOD GetCSSStyleRule(nsICSSStyleRule** aResult) = 0; NS_IMETHOD GetCSSStyleRule(mozilla::css::StyleRule** aResult) = 0;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSStyleRuleDOMWrapper, NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSStyleRuleDOMWrapper,

View File

@ -42,7 +42,7 @@
#include "nsStyleAnimation.h" #include "nsStyleAnimation.h"
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsIStyleRule.h" #include "nsIStyleRule.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsString.h" #include "nsString.h"
#include "nsStyleContext.h" #include "nsStyleContext.h"
#include "nsStyleSet.h" #include "nsStyleSet.h"
@ -1778,7 +1778,7 @@ nsStyleAnimation::AddWeighted(nsCSSProperty aProperty,
return PR_FALSE; return PR_FALSE;
} }
already_AddRefed<nsICSSStyleRule> already_AddRefed<css::StyleRule>
BuildStyleRule(nsCSSProperty aProperty, BuildStyleRule(nsCSSProperty aProperty,
nsIContent* aTargetElement, nsIContent* aTargetElement,
const nsAString& aSpecifiedValue, const nsAString& aSpecifiedValue,
@ -1870,8 +1870,8 @@ StyleWithDeclarationAdded(nsCSSProperty aProperty,
return nsnull; return nsnull;
} }
// Parse specified value into a temporary nsICSSStyleRule // Parse specified value into a temporary StyleRule
nsCOMPtr<nsICSSStyleRule> styleRule = nsRefPtr<css::StyleRule> styleRule =
BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode); BuildStyleRule(aProperty, aTargetElement, aSpecifiedValue, aUseSVGMode);
if (!styleRule) { if (!styleRule) {
return nsnull; return nsnull;

View File

@ -50,7 +50,7 @@
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsRuleWalker.h" #include "nsRuleWalker.h"
#include "nsStyleContext.h" #include "nsStyleContext.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsCSSAnonBoxes.h" #include "nsCSSAnonBoxes.h"
#include "nsCSSPseudoElements.h" #include "nsCSSPseudoElements.h"
#include "nsCSSRuleProcessor.h" #include "nsCSSRuleProcessor.h"
@ -564,7 +564,7 @@ nsStyleSet::AssertNoCSSRules(nsRuleNode* aCurrLevelNode,
for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode; for (nsRuleNode *node = aCurrLevelNode; node != aLastPrevLevelNode;
node = node->GetParent()) { node = node->GetParent()) {
nsIStyleRule *rule = node->GetRule(); nsIStyleRule *rule = node->GetRule();
nsCOMPtr<nsICSSStyleRule> cssRule(do_QueryInterface(rule)); nsRefPtr<mozilla::css::StyleRule> cssRule(do_QueryObject(rule));
NS_ASSERTION(!cssRule || !cssRule->Selector(), "Unexpected CSS rule"); NS_ASSERTION(!cssRule || !cssRule->Selector(), "Unexpected CSS rule");
} }
} }

View File

@ -74,7 +74,7 @@
#include "nsIDOMXULElement.h" #include "nsIDOMXULElement.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsICSSStyleRule.h" #include "mozilla/css/StyleRule.h"
#include "nsCSSRendering.h" #include "nsCSSRendering.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIDeviceContext.h" #include "nsIDeviceContext.h"