2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-25 05:47:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* representation of CSS style rules (selectors+declaration) and CSS
|
|
|
|
* selectors
|
|
|
|
*/
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
#ifndef mozilla_css_StyleRule_h__
|
|
|
|
#define mozilla_css_StyleRule_h__
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-12-19 18:48:15 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2011-04-08 01:23:46 +00:00
|
|
|
#include "mozilla/css/Rule.h"
|
2011-12-19 18:48:15 +00:00
|
|
|
|
1998-12-11 02:50:01 +00:00
|
|
|
#include "nsString.h"
|
2002-08-14 12:34:39 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2009-12-11 07:37:40 +00:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2009-12-11 07:37:41 +00:00
|
|
|
#include "nsCSSPseudoClasses.h"
|
1998-12-11 02:50:01 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIAtom;
|
2010-05-11 20:41:47 +00:00
|
|
|
class nsCSSStyleSheet;
|
2010-04-24 02:59:47 +00:00
|
|
|
struct nsCSSSelectorList;
|
2011-03-11 02:48:57 +00:00
|
|
|
class nsCSSCompressedDataBlock;
|
2010-06-28 22:49:35 +00:00
|
|
|
|
1998-12-11 02:50:01 +00:00
|
|
|
struct nsAtomList {
|
|
|
|
public:
|
|
|
|
nsAtomList(nsIAtom* aAtom);
|
|
|
|
nsAtomList(const nsString& aAtomValue);
|
|
|
|
~nsAtomList(void);
|
2006-04-25 21:48:11 +00:00
|
|
|
|
|
|
|
/** Do a deep clone. Should be used only on the first in the linked list. */
|
2011-10-17 14:59:28 +00:00
|
|
|
nsAtomList* Clone() const { return Clone(true); }
|
1998-12-11 02:50:01 +00:00
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2002-08-14 12:34:39 +00:00
|
|
|
nsCOMPtr<nsIAtom> mAtom;
|
|
|
|
nsAtomList* mNext;
|
2006-04-25 21:48:11 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsAtomList* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2011-12-16 19:42:07 +00:00
|
|
|
nsAtomList(const nsAtomList& aCopy) MOZ_DELETE;
|
|
|
|
nsAtomList& operator=(const nsAtomList& aCopy) MOZ_DELETE;
|
2002-08-14 12:34:39 +00:00
|
|
|
};
|
|
|
|
|
2008-06-03 03:17:35 +00:00
|
|
|
struct nsPseudoClassList {
|
2002-08-14 12:34:39 +00:00
|
|
|
public:
|
2011-03-23 13:52:25 +00:00
|
|
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType);
|
2014-01-04 15:02:17 +00:00
|
|
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType, const char16_t *aString);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType, const int32_t *aIntPair);
|
2011-03-23 13:52:25 +00:00
|
|
|
nsPseudoClassList(nsCSSPseudoClasses::Type aType,
|
2010-04-24 02:59:47 +00:00
|
|
|
nsCSSSelectorList *aSelectorList /* takes ownership */);
|
2008-06-03 03:17:35 +00:00
|
|
|
~nsPseudoClassList(void);
|
2006-04-25 21:48:11 +00:00
|
|
|
|
|
|
|
/** Do a deep clone. Should be used only on the first in the linked list. */
|
2011-10-17 14:59:28 +00:00
|
|
|
nsPseudoClassList* Clone() const { return Clone(true); }
|
2002-08-14 12:34:39 +00:00
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2008-06-03 03:17:35 +00:00
|
|
|
union {
|
2011-03-23 13:52:24 +00:00
|
|
|
// For a given value of mType, we have either:
|
2008-06-03 03:17:35 +00:00
|
|
|
// a. no value, which means mMemory is always null
|
2010-04-24 02:59:47 +00:00
|
|
|
// (if none of the conditions for (b), (c), or (d) is true)
|
2008-06-03 03:17:35 +00:00
|
|
|
// b. a string value, which means mString/mMemory is non-null
|
2011-03-23 13:52:24 +00:00
|
|
|
// (if nsCSSPseudoClasses::HasStringArg(mType))
|
2008-06-03 03:17:35 +00:00
|
|
|
// c. an integer pair value, which means mNumbers/mMemory is non-null
|
2011-03-23 13:52:24 +00:00
|
|
|
// (if nsCSSPseudoClasses::HasNthPairArg(mType))
|
2010-04-24 02:59:47 +00:00
|
|
|
// d. a selector list, which means mSelectors is non-null
|
2011-03-23 13:52:24 +00:00
|
|
|
// (if nsCSSPseudoClasses::HasSelectorListArg(mType))
|
2010-04-24 02:59:47 +00:00
|
|
|
void* mMemory; // mString and mNumbers use NS_Alloc/NS_Free
|
2014-01-04 15:02:17 +00:00
|
|
|
char16_t* mString;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t* mNumbers;
|
2010-04-24 02:59:47 +00:00
|
|
|
nsCSSSelectorList* mSelectors;
|
2008-06-03 03:17:35 +00:00
|
|
|
} u;
|
2009-12-11 07:37:41 +00:00
|
|
|
nsCSSPseudoClasses::Type mType;
|
2008-06-03 03:17:35 +00:00
|
|
|
nsPseudoClassList* mNext;
|
2006-04-25 21:48:11 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsPseudoClassList* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2011-12-16 19:42:07 +00:00
|
|
|
nsPseudoClassList(const nsPseudoClassList& aCopy) MOZ_DELETE;
|
|
|
|
nsPseudoClassList& operator=(const nsPseudoClassList& aCopy) MOZ_DELETE;
|
1998-12-11 02:50:01 +00:00
|
|
|
};
|
|
|
|
|
1998-12-20 01:19:22 +00:00
|
|
|
#define NS_ATTR_FUNC_SET 0 // [attr]
|
|
|
|
#define NS_ATTR_FUNC_EQUALS 1 // [attr=value]
|
|
|
|
#define NS_ATTR_FUNC_INCLUDES 2 // [attr~=value] (space separated)
|
|
|
|
#define NS_ATTR_FUNC_DASHMATCH 3 // [attr|=value] ('-' truncated)
|
2001-03-03 00:54:04 +00:00
|
|
|
#define NS_ATTR_FUNC_BEGINSMATCH 4 // [attr^=value] (begins with)
|
|
|
|
#define NS_ATTR_FUNC_ENDSMATCH 5 // [attr$=value] (ends with)
|
|
|
|
#define NS_ATTR_FUNC_CONTAINSMATCH 6 // [attr*=value] (contains substring)
|
1998-12-11 02:50:01 +00:00
|
|
|
|
|
|
|
struct nsAttrSelector {
|
|
|
|
public:
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAttrSelector(int32_t aNameSpace, const nsString& aAttr);
|
|
|
|
nsAttrSelector(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunction,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsString& aValue, bool aCaseSensitive);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAttrSelector(int32_t aNameSpace, nsIAtom* aLowercaseAttr,
|
|
|
|
nsIAtom* aCasedAttr, uint8_t aFunction,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsString& aValue, bool aCaseSensitive);
|
1998-12-11 02:50:01 +00:00
|
|
|
~nsAttrSelector(void);
|
2006-04-25 21:48:11 +00:00
|
|
|
|
|
|
|
/** Do a deep clone. Should be used only on the first in the linked list. */
|
2011-10-17 14:59:28 +00:00
|
|
|
nsAttrSelector* Clone() const { return Clone(true); }
|
1998-12-11 02:50:01 +00:00
|
|
|
|
2009-05-13 08:26:48 +00:00
|
|
|
nsString mValue;
|
|
|
|
nsAttrSelector* mNext;
|
2009-09-29 06:07:45 +00:00
|
|
|
nsCOMPtr<nsIAtom> mLowercaseAttr;
|
|
|
|
nsCOMPtr<nsIAtom> mCasedAttr;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mNameSpace;
|
|
|
|
uint8_t mFunction;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mCaseSensitive; // If we are in an HTML document,
|
2009-09-29 06:07:45 +00:00
|
|
|
// is the value case sensitive?
|
2006-04-25 21:48:11 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsAttrSelector* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2011-12-16 19:42:07 +00:00
|
|
|
nsAttrSelector(const nsAttrSelector& aCopy) MOZ_DELETE;
|
|
|
|
nsAttrSelector& operator=(const nsAttrSelector& aCopy) MOZ_DELETE;
|
1998-12-11 02:50:01 +00:00
|
|
|
};
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
struct nsCSSSelector {
|
|
|
|
public:
|
1998-12-11 02:50:01 +00:00
|
|
|
nsCSSSelector(void);
|
|
|
|
~nsCSSSelector(void);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-04-25 21:48:11 +00:00
|
|
|
/** Do a deep clone. Should be used only on the first in the linked list. */
|
2011-10-17 14:59:28 +00:00
|
|
|
nsCSSSelector* Clone() const { return Clone(true, true); }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-12-11 02:50:01 +00:00
|
|
|
void Reset(void);
|
2012-08-22 15:56:38 +00:00
|
|
|
void SetNameSpace(int32_t aNameSpace);
|
2009-09-29 06:07:45 +00:00
|
|
|
void SetTag(const nsString& aTag);
|
2001-02-13 14:06:29 +00:00
|
|
|
void AddID(const nsString& aID);
|
1998-12-11 02:50:01 +00:00
|
|
|
void AddClass(const nsString& aClass);
|
2011-03-23 13:52:25 +00:00
|
|
|
void AddPseudoClass(nsCSSPseudoClasses::Type aType);
|
2014-01-04 15:02:17 +00:00
|
|
|
void AddPseudoClass(nsCSSPseudoClasses::Type aType, const char16_t* aString);
|
2012-08-22 15:56:38 +00:00
|
|
|
void AddPseudoClass(nsCSSPseudoClasses::Type aType, const int32_t* aIntPair);
|
2010-04-24 02:59:47 +00:00
|
|
|
// takes ownership of aSelectorList
|
2011-03-23 13:52:25 +00:00
|
|
|
void AddPseudoClass(nsCSSPseudoClasses::Type aType,
|
2010-04-24 02:59:47 +00:00
|
|
|
nsCSSSelectorList* aSelectorList);
|
2012-08-22 15:56:38 +00:00
|
|
|
void AddAttribute(int32_t aNameSpace, const nsString& aAttr);
|
|
|
|
void AddAttribute(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunc,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsString& aValue, bool aCaseSensitive);
|
2014-01-04 15:02:17 +00:00
|
|
|
void SetOperator(char16_t aOperator);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
inline bool HasTagSelector() const {
|
2009-08-01 15:53:40 +00:00
|
|
|
return !!mCasedTag;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
inline bool IsPseudoElement() const {
|
2009-08-01 15:53:40 +00:00
|
|
|
return mLowercaseTag && !mCasedTag;
|
|
|
|
}
|
|
|
|
|
2009-01-17 03:44:21 +00:00
|
|
|
// Calculate the specificity of this selector (not including its mNext!).
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t CalcWeight() const;
|
2000-03-31 07:08:36 +00:00
|
|
|
|
2010-05-11 20:41:47 +00:00
|
|
|
void ToString(nsAString& aString, nsCSSStyleSheet* aSheet,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAppend = false) const;
|
2001-03-20 11:49:20 +00:00
|
|
|
|
|
|
|
private:
|
2008-06-03 03:17:35 +00:00
|
|
|
void AddPseudoClassInternal(nsPseudoClassList *aPseudoClass);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsCSSSelector* Clone(bool aDeepNext, bool aDeepNegations) const;
|
2001-03-20 11:49:20 +00:00
|
|
|
|
2009-02-19 21:55:48 +00:00
|
|
|
void AppendToStringWithoutCombinators(nsAString& aString,
|
2010-05-11 20:41:47 +00:00
|
|
|
nsCSSStyleSheet* aSheet) const;
|
2009-02-19 21:55:48 +00:00
|
|
|
void AppendToStringWithoutCombinatorsOrNegations(nsAString& aString,
|
2010-05-11 20:41:47 +00:00
|
|
|
nsCSSStyleSheet* aSheet,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsNegated)
|
2009-02-19 21:55:48 +00:00
|
|
|
const;
|
2008-11-12 03:36:20 +00:00
|
|
|
// Returns true if this selector can have a namespace specified (which
|
|
|
|
// happens if and only if the default namespace would apply to this
|
|
|
|
// selector).
|
2011-09-29 06:19:26 +00:00
|
|
|
bool CanBeNamespaced(bool aIsNegated) const;
|
2009-01-17 03:44:21 +00:00
|
|
|
// Calculate the specificity of this selector (not including its mNext
|
|
|
|
// or its mNegations).
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t CalcWeightWithoutNegations() const;
|
2000-03-31 07:08:36 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
public:
|
2009-12-11 07:37:40 +00:00
|
|
|
// Get and set the selector's pseudo type
|
|
|
|
nsCSSPseudoElements::Type PseudoType() const {
|
|
|
|
return static_cast<nsCSSPseudoElements::Type>(mPseudoType);
|
|
|
|
}
|
|
|
|
void SetPseudoType(nsCSSPseudoElements::Type aType) {
|
2012-10-02 19:50:50 +00:00
|
|
|
NS_ASSERTION(static_cast<int32_t>(aType) >= INT16_MIN &&
|
|
|
|
static_cast<int32_t>(aType) <= INT16_MAX,
|
|
|
|
"Out of bounds - this will overflow mPseudoType");
|
2012-08-22 15:56:38 +00:00
|
|
|
mPseudoType = static_cast<int16_t>(aType);
|
2009-12-11 07:37:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2009-08-01 15:53:40 +00:00
|
|
|
// For case-sensitive documents, mLowercaseTag is the same as mCasedTag,
|
|
|
|
// but in case-insensitive documents (HTML) mLowercaseTag is lowercase.
|
|
|
|
// Also, for pseudo-elements mCasedTag will be null but mLowercaseTag
|
|
|
|
// contains their name.
|
|
|
|
nsCOMPtr<nsIAtom> mLowercaseTag;
|
|
|
|
nsCOMPtr<nsIAtom> mCasedTag;
|
2001-02-13 14:06:29 +00:00
|
|
|
nsAtomList* mIDList;
|
1998-12-11 02:50:01 +00:00
|
|
|
nsAtomList* mClassList;
|
2008-06-03 03:17:35 +00:00
|
|
|
nsPseudoClassList* mPseudoClassList; // atom for the pseudo, string for
|
|
|
|
// the argument to functional pseudos
|
1998-12-11 02:50:01 +00:00
|
|
|
nsAttrSelector* mAttrList;
|
2001-03-20 11:49:20 +00:00
|
|
|
nsCSSSelector* mNegations;
|
1998-04-13 20:24:54 +00:00
|
|
|
nsCSSSelector* mNext;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mNameSpace;
|
2014-01-04 15:02:17 +00:00
|
|
|
char16_t mOperator;
|
2009-12-11 07:37:40 +00:00
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
// int16_t to make sure it packs well with mOperator
|
|
|
|
int16_t mPseudoType;
|
2011-12-16 19:42:07 +00:00
|
|
|
|
|
|
|
nsCSSSelector(const nsCSSSelector& aCopy) MOZ_DELETE;
|
|
|
|
nsCSSSelector& operator=(const nsCSSSelector& aCopy) MOZ_DELETE;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2003-06-14 23:50:54 +00:00
|
|
|
/**
|
|
|
|
* A selector list is the unit of selectors that each style rule has.
|
|
|
|
* For example, "P B, H1 B { ... }" would be a selector list with two
|
|
|
|
* items (where each |nsCSSSelectorList| object's |mSelectors| has
|
|
|
|
* an |mNext| for the P or H1). We represent them as linked lists.
|
|
|
|
*/
|
2013-02-13 15:11:53 +00:00
|
|
|
class inDOMUtils;
|
|
|
|
|
2003-06-14 23:50:54 +00:00
|
|
|
struct nsCSSSelectorList {
|
|
|
|
nsCSSSelectorList(void);
|
|
|
|
~nsCSSSelectorList(void);
|
|
|
|
|
|
|
|
/**
|
2010-03-31 18:08:09 +00:00
|
|
|
* Create a new selector and push it onto the beginning of |mSelectors|,
|
|
|
|
* setting its |mNext| to the current value of |mSelectors|. If there is an
|
|
|
|
* earlier selector, set its |mOperator| to |aOperator|; else |aOperator|
|
2014-01-04 15:02:17 +00:00
|
|
|
* must be char16_t(0).
|
2010-03-31 18:08:09 +00:00
|
|
|
* Returns the new selector.
|
|
|
|
* The list owns the new selector.
|
2003-06-14 23:50:54 +00:00
|
|
|
* The caller is responsible for updating |mWeight|.
|
|
|
|
*/
|
2014-01-04 15:02:17 +00:00
|
|
|
nsCSSSelector* AddSelector(char16_t aOperator);
|
2003-06-14 23:50:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Should be used only on the first in the list
|
|
|
|
*/
|
2010-05-11 20:41:47 +00:00
|
|
|
void ToString(nsAString& aResult, nsCSSStyleSheet* aSheet);
|
2003-06-14 23:50:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Do a deep clone. Should be used only on the first in the list.
|
|
|
|
*/
|
2011-10-17 14:59:28 +00:00
|
|
|
nsCSSSelectorList* Clone() const { return Clone(true); }
|
2003-06-14 23:50:54 +00:00
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2003-06-14 23:50:54 +00:00
|
|
|
nsCSSSelector* mSelectors;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mWeight;
|
2003-06-14 23:50:54 +00:00
|
|
|
nsCSSSelectorList* mNext;
|
2013-02-13 15:11:53 +00:00
|
|
|
protected:
|
|
|
|
friend class inDOMUtils;
|
2011-09-29 06:19:26 +00:00
|
|
|
nsCSSSelectorList* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2013-02-13 15:11:53 +00:00
|
|
|
private:
|
2011-12-16 19:42:07 +00:00
|
|
|
nsCSSSelectorList(const nsCSSSelectorList& aCopy) MOZ_DELETE;
|
|
|
|
nsCSSSelectorList& operator=(const nsCSSSelectorList& aCopy) MOZ_DELETE;
|
2003-06-14 23:50:54 +00:00
|
|
|
};
|
2001-03-20 11:49:20 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
// 464bab7a-2fce-4f30-ab44-b7a5f3aae57d
|
|
|
|
#define NS_CSS_STYLE_RULE_IMPL_CID \
|
|
|
|
{ 0x464bab7a, 0x2fce, 0x4f30, \
|
|
|
|
{ 0xab, 0x44, 0xb7, 0xa5, 0xf3, 0xaa, 0xe5, 0x7d } }
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
class Declaration;
|
|
|
|
class DOMCSSStyleRule;
|
|
|
|
|
2011-05-23 20:45:44 +00:00
|
|
|
class StyleRule;
|
|
|
|
|
|
|
|
class ImportantRule : public nsIStyleRule {
|
|
|
|
public:
|
|
|
|
ImportantRule(Declaration *aDeclaration);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIStyleRule interface
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
|
2011-05-23 20:45:44 +00:00
|
|
|
#ifdef DEBUG
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2011-05-23 20:45:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~ImportantRule();
|
|
|
|
|
|
|
|
// Not an owning reference; the StyleRule that owns this
|
|
|
|
// ImportantRule also owns the mDeclaration, and any rule node
|
|
|
|
// pointing to this rule keeps that StyleRule alive as well.
|
|
|
|
Declaration* mDeclaration;
|
|
|
|
|
|
|
|
friend class StyleRule;
|
|
|
|
};
|
|
|
|
|
2011-12-19 18:48:15 +00:00
|
|
|
class StyleRule MOZ_FINAL : public Rule
|
2011-03-29 03:21:20 +00:00
|
|
|
{
|
2011-03-11 02:48:57 +00:00
|
|
|
public:
|
|
|
|
StyleRule(nsCSSSelectorList* aSelector,
|
|
|
|
Declaration *aDeclaration);
|
|
|
|
private:
|
|
|
|
// for |Clone|
|
|
|
|
StyleRule(const StyleRule& aCopy);
|
|
|
|
// for |DeclarationChanged|
|
|
|
|
StyleRule(StyleRule& aCopy,
|
|
|
|
Declaration *aDeclaration);
|
1998-04-13 20:24:54 +00:00
|
|
|
public:
|
2011-03-11 02:48:57 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_RULE_IMPL_CID)
|
|
|
|
|
2012-10-08 02:39:09 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
1998-12-18 03:43:29 +00:00
|
|
|
|
2003-06-14 23:50:54 +00:00
|
|
|
// null for style attribute
|
2011-03-11 02:50:12 +00:00
|
|
|
nsCSSSelectorList* Selector() { return mSelector; }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t GetLineNumber() const { return mLineNumber; }
|
2013-04-06 17:38:56 +00:00
|
|
|
uint32_t GetColumnNumber() const { return mColumnNumber; }
|
|
|
|
void SetLineNumberAndColumnNumber(uint32_t aLineNumber,
|
|
|
|
uint32_t aColumnNumber)
|
|
|
|
{ mLineNumber = aLineNumber; mColumnNumber = aColumnNumber; }
|
2001-01-22 04:03:48 +00:00
|
|
|
|
2011-03-11 02:50:12 +00:00
|
|
|
Declaration* GetDeclaration() const { return mDeclaration; }
|
2003-06-18 01:59:57 +00:00
|
|
|
|
|
|
|
/**
|
2010-07-23 18:00:47 +00:00
|
|
|
* Return a new |nsIStyleRule| instance that replaces the current
|
|
|
|
* one, with |aDecl| replacing the previous declaration. Due to the
|
|
|
|
* |nsIStyleRule| contract of immutability, this must be called if
|
|
|
|
* the declaration is modified.
|
2003-06-18 01:59:57 +00:00
|
|
|
*
|
|
|
|
* |DeclarationChanged| handles replacing the object in the container
|
|
|
|
* sheet or group rule if |aHandleContainer| is true.
|
|
|
|
*/
|
2011-03-11 02:50:12 +00:00
|
|
|
already_AddRefed<StyleRule>
|
2011-09-29 06:19:26 +00:00
|
|
|
DeclarationChanged(Declaration* aDecl, bool aHandleContainer);
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2011-05-23 20:45:44 +00:00
|
|
|
nsIStyleRule* GetImportantRule() const { return mImportantRule; }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2009-12-11 16:13:19 +00:00
|
|
|
/**
|
|
|
|
* The rule processor must call this method before calling
|
|
|
|
* nsRuleWalker::Forward on this rule during rule matching.
|
|
|
|
*/
|
2011-03-11 02:50:12 +00:00
|
|
|
void RuleMatched();
|
2009-12-11 16:13:19 +00:00
|
|
|
|
2003-06-24 05:40:37 +00:00
|
|
|
// hooks for DOM rule
|
2011-03-11 02:50:20 +00:00
|
|
|
void GetCssText(nsAString& aCssText);
|
|
|
|
void SetCssText(const nsAString& aCssText);
|
|
|
|
void GetSelectorText(nsAString& aSelectorText);
|
|
|
|
void SetSelectorText(const nsAString& aSelectorText);
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetType() const;
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2011-04-08 01:23:46 +00:00
|
|
|
virtual already_AddRefed<Rule> Clone() const;
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2011-04-08 06:36:09 +00:00
|
|
|
virtual nsIDOMCSSRule* GetDOMRule();
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2012-10-08 02:39:08 +00:00
|
|
|
virtual nsIDOMCSSRule* GetExistingDOMRule();
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
// The new mapping function.
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
|
2011-03-11 02:48:57 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2011-03-11 02:48:57 +00:00
|
|
|
#endif
|
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
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.
|
2013-04-06 17:38:56 +00:00
|
|
|
uint32_t mLineNumber;
|
|
|
|
uint32_t mColumnNumber : 31;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mWasMatched : 1;
|
2011-12-16 19:42:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
StyleRule& operator=(const StyleRule& aCopy) MOZ_DELETE;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
} // namespace css
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(mozilla::css::StyleRule, NS_CSS_STYLE_RULE_IMPL_CID)
|
2005-11-11 14:36:26 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
#endif /* mozilla_css_StyleRule_h__ */
|