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"
|
2017-01-13 15:41:02 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-01-20 18:30:14 +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"
|
2016-02-17 20:37:00 +00:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2015-11-05 08:44:10 +00:00
|
|
|
#include "nsIStyleRule.h"
|
2017-01-13 15:41:02 +00:00
|
|
|
#include "nsICSSStyleRuleDOMWrapper.h"
|
1998-12-11 02:50:01 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIAtom;
|
2010-04-24 02:59:47 +00:00
|
|
|
struct nsCSSSelectorList;
|
2010-06-28 22:49:35 +00:00
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
namespace mozilla {
|
2016-04-22 13:38:46 +00:00
|
|
|
enum class CSSPseudoClassType : uint8_t;
|
2014-06-20 10:32:49 +00:00
|
|
|
class CSSStyleSheet;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
1998-12-11 02:50:01 +00:00
|
|
|
struct nsAtomList {
|
|
|
|
public:
|
2014-08-20 04:58:22 +00:00
|
|
|
explicit nsAtomList(nsIAtom* aAtom);
|
|
|
|
explicit nsAtomList(const nsString& aAtomValue);
|
1998-12-11 02:50:01 +00:00
|
|
|
~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;
|
2016-04-22 13:38:46 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsAtomList* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2015-01-06 23:35:02 +00:00
|
|
|
nsAtomList(const nsAtomList& aCopy) = delete;
|
|
|
|
nsAtomList& operator=(const nsAtomList& aCopy) = 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:
|
2016-04-22 13:38:46 +00:00
|
|
|
typedef mozilla::CSSPseudoClassType CSSPseudoClassType;
|
|
|
|
|
|
|
|
explicit nsPseudoClassList(CSSPseudoClassType aType);
|
|
|
|
nsPseudoClassList(CSSPseudoClassType aType, const char16_t *aString);
|
|
|
|
nsPseudoClassList(CSSPseudoClassType aType, const int32_t *aIntPair);
|
|
|
|
nsPseudoClassList(CSSPseudoClassType 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))
|
2015-04-01 05:29:55 +00:00
|
|
|
void* mMemory; // mString and mNumbers use moz_xmalloc/free
|
2016-04-22 13:38:46 +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;
|
2016-04-22 13:38:46 +00:00
|
|
|
CSSPseudoClassType mType;
|
2008-06-03 03:17:35 +00:00
|
|
|
nsPseudoClassList* mNext;
|
2016-04-22 13:38:46 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsPseudoClassList* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2015-01-06 23:35:02 +00:00
|
|
|
nsPseudoClassList(const nsPseudoClassList& aCopy) = delete;
|
|
|
|
nsPseudoClassList& operator=(const nsPseudoClassList& aCopy) = 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:
|
2016-01-26 19:55:52 +00:00
|
|
|
enum class ValueCaseSensitivity : uint8_t {
|
|
|
|
CaseSensitive,
|
|
|
|
CaseInsensitive,
|
|
|
|
CaseInsensitiveInHTML
|
|
|
|
};
|
|
|
|
|
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,
|
2016-01-26 19:55:52 +00:00
|
|
|
const nsString& aValue,
|
|
|
|
ValueCaseSensitivity aValueCaseSensitivity);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAttrSelector(int32_t aNameSpace, nsIAtom* aLowercaseAttr,
|
|
|
|
nsIAtom* aCasedAttr, uint8_t aFunction,
|
2016-01-26 19:55:52 +00:00
|
|
|
const nsString& aValue,
|
|
|
|
ValueCaseSensitivity aValueCaseSensitivity);
|
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
|
|
|
|
2015-10-21 05:18:36 +00:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
2016-01-26 19:55:52 +00:00
|
|
|
bool IsValueCaseSensitive(bool aInHTML) const {
|
|
|
|
return mValueCaseSensitivity == ValueCaseSensitivity::CaseSensitive ||
|
|
|
|
(!aInHTML &&
|
|
|
|
mValueCaseSensitivity == ValueCaseSensitivity::CaseInsensitiveInHTML);
|
|
|
|
}
|
|
|
|
|
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;
|
2016-01-26 19:55:52 +00:00
|
|
|
ValueCaseSensitivity mValueCaseSensitivity;
|
|
|
|
|
2016-04-22 13:38:46 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
nsAttrSelector* Clone(bool aDeep) const;
|
2006-04-25 21:48:11 +00:00
|
|
|
|
2015-01-06 23:35:02 +00:00
|
|
|
nsAttrSelector(const nsAttrSelector& aCopy) = delete;
|
|
|
|
nsAttrSelector& operator=(const nsAttrSelector& aCopy) = delete;
|
1998-12-11 02:50:01 +00:00
|
|
|
};
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
struct nsCSSSelector {
|
|
|
|
public:
|
2016-04-22 13:38:46 +00:00
|
|
|
typedef mozilla::CSSPseudoClassType CSSPseudoClassType;
|
|
|
|
|
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);
|
2016-04-22 13:38:46 +00:00
|
|
|
void AddPseudoClass(CSSPseudoClassType aType);
|
|
|
|
void AddPseudoClass(CSSPseudoClassType aType, const char16_t* aString);
|
|
|
|
void AddPseudoClass(CSSPseudoClassType aType, const int32_t* aIntPair);
|
2010-04-24 02:59:47 +00:00
|
|
|
// takes ownership of aSelectorList
|
2016-04-22 13:38:46 +00:00
|
|
|
void AddPseudoClass(CSSPseudoClassType 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);
|
2016-04-22 13:38:46 +00:00
|
|
|
void AddAttribute(int32_t aNameSpace, const nsString& aAttr, uint8_t aFunc,
|
2016-01-26 19:55:52 +00:00
|
|
|
const nsString& aValue,
|
|
|
|
nsAttrSelector::ValueCaseSensitivity aValueCaseSensitivity);
|
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
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
void ToString(nsAString& aString, mozilla::CSSStyleSheet* aSheet,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAppend = false) const;
|
2001-03-20 11:49:20 +00:00
|
|
|
|
2015-08-05 12:42:20 +00:00
|
|
|
bool IsRestrictedSelector() const {
|
2016-02-16 22:07:00 +00:00
|
|
|
return PseudoType() == mozilla::CSSPseudoElementType::NotPseudo;
|
2015-08-05 12:42:20 +00:00
|
|
|
}
|
|
|
|
|
2015-08-05 12:42:21 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsCString RestrictedSelectorToString() const;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2015-08-05 12:42:21 +00:00
|
|
|
void AppendToStringWithoutCombinators(
|
|
|
|
nsAString& aString,
|
|
|
|
mozilla::CSSStyleSheet* aSheet,
|
|
|
|
bool aUseStandardNamespacePrefixes) const;
|
|
|
|
void AppendToStringWithoutCombinatorsOrNegations(
|
|
|
|
nsAString& aString,
|
|
|
|
mozilla::CSSStyleSheet* aSheet,
|
|
|
|
bool aIsNegated,
|
|
|
|
bool aUseStandardNamespacePrefixes) 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
|
2016-02-17 21:04:00 +00:00
|
|
|
mozilla::CSSPseudoElementType PseudoType() const { return mPseudoType; }
|
2016-02-17 20:37:00 +00:00
|
|
|
void SetPseudoType(mozilla::CSSPseudoElementType aType) {
|
2016-02-17 21:04:00 +00:00
|
|
|
mPseudoType = 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:
|
2016-02-17 21:04:00 +00:00
|
|
|
// The underlying type of CSSPseudoElementType is uint8_t and
|
|
|
|
// it packs well with mOperator. (char16_t + uint8_t is less than 32bits.)
|
|
|
|
mozilla::CSSPseudoElementType mPseudoType;
|
2011-12-16 19:42:07 +00:00
|
|
|
|
2015-01-06 23:35:02 +00:00
|
|
|
nsCSSSelector(const nsCSSSelector& aCopy) = delete;
|
|
|
|
nsCSSSelector& operator=(const nsCSSSelector& aCopy) = 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
|
|
|
|
2014-07-18 18:30:00 +00:00
|
|
|
/**
|
|
|
|
* Point |mSelectors| to its |mNext|, and delete the first node in the old
|
|
|
|
* |mSelectors|.
|
|
|
|
* Should only be used on a list with more than one selector in it.
|
|
|
|
*/
|
|
|
|
void RemoveRightmostSelector();
|
|
|
|
|
2003-06-14 23:50:54 +00:00
|
|
|
/**
|
|
|
|
* Should be used only on the first in the list
|
|
|
|
*/
|
2014-06-20 10:32:49 +00:00
|
|
|
void ToString(nsAString& aResult, mozilla::CSSStyleSheet* 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:
|
2015-01-06 23:35:02 +00:00
|
|
|
nsCSSSelectorList(const nsCSSSelectorList& aCopy) = delete;
|
|
|
|
nsCSSSelectorList& operator=(const nsCSSSelectorList& aCopy) = 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 } }
|
|
|
|
|
2017-01-13 15:41:02 +00:00
|
|
|
class DOMCSSDeclarationImpl;
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
class Declaration;
|
|
|
|
|
2017-01-20 18:30:14 +00:00
|
|
|
class StyleRule final : public Rule
|
2017-01-13 15:41:02 +00:00
|
|
|
, public nsICSSStyleRuleDOMWrapper
|
2011-03-29 03:21:20 +00:00
|
|
|
{
|
2011-03-11 02:48:57 +00:00
|
|
|
public:
|
|
|
|
StyleRule(nsCSSSelectorList* aSelector,
|
2014-07-14 22:57:02 +00:00
|
|
|
Declaration *aDeclaration,
|
2014-07-14 22:57:54 +00:00
|
|
|
uint32_t aLineNumber, uint32_t aColumnNumber);
|
2011-03-11 02:48:57 +00:00
|
|
|
private:
|
|
|
|
// for |Clone|
|
|
|
|
StyleRule(const StyleRule& aCopy);
|
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)
|
|
|
|
|
2016-11-30 23:18:14 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2017-01-13 15:41:02 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(StyleRule, Rule)
|
2016-11-30 23:18:14 +00:00
|
|
|
virtual bool IsCCLeaf() const override;
|
2017-01-13 15:41:02 +00:00
|
|
|
|
2017-01-13 15:41:02 +00:00
|
|
|
NS_DECL_NSIDOMCSSSTYLERULE
|
|
|
|
|
|
|
|
// nsICSSStyleRuleDOMWrapper
|
|
|
|
NS_IMETHOD GetCSSStyleRule(StyleRule **aResult) override;
|
|
|
|
|
2017-01-13 15:41:02 +00:00
|
|
|
// WebIDL interface
|
|
|
|
uint16_t Type() const override;
|
|
|
|
void GetCssTextImpl(nsAString& aCssText) const override;
|
|
|
|
|
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
|
|
|
|
2011-03-11 02:50:12 +00:00
|
|
|
Declaration* GetDeclaration() const { return mDeclaration; }
|
2003-06-18 01:59:57 +00:00
|
|
|
|
2015-11-09 07:57:17 +00:00
|
|
|
void SetDeclaration(Declaration* aDecl);
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual int32_t GetType() const override;
|
2017-01-13 15:41:02 +00:00
|
|
|
using Rule::GetType;
|
2011-03-11 02:48:57 +00:00
|
|
|
|
2016-11-22 23:26:20 +00:00
|
|
|
CSSStyleSheet* GetStyleSheet() const
|
|
|
|
{
|
|
|
|
StyleSheet* sheet = Rule::GetStyleSheet();
|
|
|
|
return sheet ? sheet->AsGecko() : nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual already_AddRefed<Rule> Clone() const override;
|
2011-03-11 02:48:57 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
|
2011-03-11 02:48:57 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
2012-01-03 02:19:14 +00:00
|
|
|
|
2017-01-13 15:41:02 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
private:
|
|
|
|
~StyleRule();
|
|
|
|
|
2016-11-30 23:18:14 +00:00
|
|
|
// Drop our references to mDeclaration and mRule, and let them know we're
|
|
|
|
// doing that.
|
|
|
|
void DropReferences();
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
private:
|
|
|
|
nsCSSSelectorList* mSelector; // null for style attribute
|
2015-11-05 08:44:08 +00:00
|
|
|
RefPtr<Declaration> mDeclaration;
|
2017-01-13 15:41:02 +00:00
|
|
|
|
|
|
|
// We own it, and it aggregates its refcount with us.
|
|
|
|
UniquePtr<DOMCSSDeclarationImpl> mDOMDeclaration;
|
2011-12-16 19:42:07 +00:00
|
|
|
|
|
|
|
private:
|
2015-01-06 23:35:02 +00:00
|
|
|
StyleRule& operator=(const StyleRule& aCopy) = delete;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2014-03-28 08:45:02 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(StyleRule, NS_CSS_STYLE_RULE_IMPL_CID)
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
} // namespace css
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_css_StyleRule_h__ */
|