michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* atom list for CSS pseudo-elements */ michael@0: michael@0: #ifndef nsCSSPseudoElements_h___ michael@0: #define nsCSSPseudoElements_h___ michael@0: michael@0: #include "nsIAtom.h" michael@0: michael@0: // Is this pseudo-element a CSS2 pseudo-element that can be specified michael@0: // with the single colon syntax (in addition to the double-colon syntax, michael@0: // which can be used for all pseudo-elements)? michael@0: #define CSS_PSEUDO_ELEMENT_IS_CSS2 (1<<0) michael@0: // Is this pseudo-element a pseudo-element that can contain other michael@0: // elements? michael@0: // (Currently pseudo-elements are either leaves of the tree (relative to michael@0: // real elements) or they contain other elements in a non-tree-like michael@0: // manner (i.e., like incorrectly-nested start and end tags). It's michael@0: // possible that in the future there might be container pseudo-elements michael@0: // that form a properly nested tree structure. If that happens, we michael@0: // should probably split this flag into two.) michael@0: #define CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS (1<<1) michael@0: // Flag to add the ability to take into account style attribute set for the michael@0: // pseudo element (by default it's ignored). michael@0: #define CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE (1<<2) michael@0: // Flag that indicate the pseudo-element supports a user action pseudo-class michael@0: // following it, such as :active or :hover. This would normally correspond michael@0: // to whether the pseudo-element is tree-like, but we don't support these michael@0: // pseudo-classes on ::before and ::after generated content yet. See michael@0: // http://dev.w3.org/csswg/selectors4/#pseudo-elements. michael@0: #define CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE (1<<3) michael@0: // Is content prevented from parsing selectors containing this pseudo-element? michael@0: #define CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY (1<<4) michael@0: michael@0: // Empty class derived from nsIAtom so that function signatures can michael@0: // require an atom from this atom list. michael@0: class nsICSSPseudoElement : public nsIAtom {}; michael@0: michael@0: class nsCSSPseudoElements { michael@0: public: michael@0: michael@0: static void AddRefAtoms(); michael@0: michael@0: static bool IsPseudoElement(nsIAtom *aAtom); michael@0: michael@0: static bool IsCSS2PseudoElement(nsIAtom *aAtom); michael@0: michael@0: #define CSS_PSEUDO_ELEMENT(_name, _value, _flags) \ michael@0: static nsICSSPseudoElement* _name; michael@0: #include "nsCSSPseudoElementList.h" michael@0: #undef CSS_PSEUDO_ELEMENT michael@0: michael@0: enum Type { michael@0: // If the actual pseudo-elements stop being first here, change michael@0: // GetPseudoType. michael@0: #define CSS_PSEUDO_ELEMENT(_name, _value_, _flags) \ michael@0: ePseudo_##_name, michael@0: #include "nsCSSPseudoElementList.h" michael@0: #undef CSS_PSEUDO_ELEMENT michael@0: ePseudo_PseudoElementCount, michael@0: ePseudo_AnonBox = ePseudo_PseudoElementCount, michael@0: #ifdef MOZ_XUL michael@0: ePseudo_XULTree, michael@0: #endif michael@0: ePseudo_NotPseudoElement, michael@0: ePseudo_MAX michael@0: }; michael@0: michael@0: static Type GetPseudoType(nsIAtom* aAtom); michael@0: michael@0: // Get the atom for a given Type. aType must be < ePseudo_PseudoElementCount michael@0: static nsIAtom* GetPseudoAtom(Type aType); michael@0: michael@0: static bool PseudoElementContainsElements(const Type aType) { michael@0: return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS); michael@0: } michael@0: michael@0: static bool PseudoElementSupportsStyleAttribute(const Type aType) { michael@0: MOZ_ASSERT(aType < ePseudo_PseudoElementCount); michael@0: return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE); michael@0: } michael@0: michael@0: static bool PseudoElementSupportsUserActionState(const Type aType); michael@0: michael@0: static bool PseudoElementIsChromeOnly(const Type aType) { michael@0: MOZ_ASSERT(aType < ePseudo_PseudoElementCount); michael@0: return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY); michael@0: } michael@0: michael@0: private: michael@0: static uint32_t FlagsForPseudoElement(const Type aType); michael@0: michael@0: // Does the given pseudo-element have all of the flags given? michael@0: static bool PseudoElementHasFlags(const Type aType, uint32_t aFlags) michael@0: { michael@0: return (FlagsForPseudoElement(aType) & aFlags) == aFlags; michael@0: } michael@0: }; michael@0: michael@0: #endif /* nsCSSPseudoElements_h___ */