Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* atom list for CSS pseudo-elements */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsCSSPseudoElements_h___ |
michael@0 | 9 | #define nsCSSPseudoElements_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "nsIAtom.h" |
michael@0 | 12 | |
michael@0 | 13 | // Is this pseudo-element a CSS2 pseudo-element that can be specified |
michael@0 | 14 | // with the single colon syntax (in addition to the double-colon syntax, |
michael@0 | 15 | // which can be used for all pseudo-elements)? |
michael@0 | 16 | #define CSS_PSEUDO_ELEMENT_IS_CSS2 (1<<0) |
michael@0 | 17 | // Is this pseudo-element a pseudo-element that can contain other |
michael@0 | 18 | // elements? |
michael@0 | 19 | // (Currently pseudo-elements are either leaves of the tree (relative to |
michael@0 | 20 | // real elements) or they contain other elements in a non-tree-like |
michael@0 | 21 | // manner (i.e., like incorrectly-nested start and end tags). It's |
michael@0 | 22 | // possible that in the future there might be container pseudo-elements |
michael@0 | 23 | // that form a properly nested tree structure. If that happens, we |
michael@0 | 24 | // should probably split this flag into two.) |
michael@0 | 25 | #define CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS (1<<1) |
michael@0 | 26 | // Flag to add the ability to take into account style attribute set for the |
michael@0 | 27 | // pseudo element (by default it's ignored). |
michael@0 | 28 | #define CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE (1<<2) |
michael@0 | 29 | // Flag that indicate the pseudo-element supports a user action pseudo-class |
michael@0 | 30 | // following it, such as :active or :hover. This would normally correspond |
michael@0 | 31 | // to whether the pseudo-element is tree-like, but we don't support these |
michael@0 | 32 | // pseudo-classes on ::before and ::after generated content yet. See |
michael@0 | 33 | // http://dev.w3.org/csswg/selectors4/#pseudo-elements. |
michael@0 | 34 | #define CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE (1<<3) |
michael@0 | 35 | // Is content prevented from parsing selectors containing this pseudo-element? |
michael@0 | 36 | #define CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY (1<<4) |
michael@0 | 37 | |
michael@0 | 38 | // Empty class derived from nsIAtom so that function signatures can |
michael@0 | 39 | // require an atom from this atom list. |
michael@0 | 40 | class nsICSSPseudoElement : public nsIAtom {}; |
michael@0 | 41 | |
michael@0 | 42 | class nsCSSPseudoElements { |
michael@0 | 43 | public: |
michael@0 | 44 | |
michael@0 | 45 | static void AddRefAtoms(); |
michael@0 | 46 | |
michael@0 | 47 | static bool IsPseudoElement(nsIAtom *aAtom); |
michael@0 | 48 | |
michael@0 | 49 | static bool IsCSS2PseudoElement(nsIAtom *aAtom); |
michael@0 | 50 | |
michael@0 | 51 | #define CSS_PSEUDO_ELEMENT(_name, _value, _flags) \ |
michael@0 | 52 | static nsICSSPseudoElement* _name; |
michael@0 | 53 | #include "nsCSSPseudoElementList.h" |
michael@0 | 54 | #undef CSS_PSEUDO_ELEMENT |
michael@0 | 55 | |
michael@0 | 56 | enum Type { |
michael@0 | 57 | // If the actual pseudo-elements stop being first here, change |
michael@0 | 58 | // GetPseudoType. |
michael@0 | 59 | #define CSS_PSEUDO_ELEMENT(_name, _value_, _flags) \ |
michael@0 | 60 | ePseudo_##_name, |
michael@0 | 61 | #include "nsCSSPseudoElementList.h" |
michael@0 | 62 | #undef CSS_PSEUDO_ELEMENT |
michael@0 | 63 | ePseudo_PseudoElementCount, |
michael@0 | 64 | ePseudo_AnonBox = ePseudo_PseudoElementCount, |
michael@0 | 65 | #ifdef MOZ_XUL |
michael@0 | 66 | ePseudo_XULTree, |
michael@0 | 67 | #endif |
michael@0 | 68 | ePseudo_NotPseudoElement, |
michael@0 | 69 | ePseudo_MAX |
michael@0 | 70 | }; |
michael@0 | 71 | |
michael@0 | 72 | static Type GetPseudoType(nsIAtom* aAtom); |
michael@0 | 73 | |
michael@0 | 74 | // Get the atom for a given Type. aType must be < ePseudo_PseudoElementCount |
michael@0 | 75 | static nsIAtom* GetPseudoAtom(Type aType); |
michael@0 | 76 | |
michael@0 | 77 | static bool PseudoElementContainsElements(const Type aType) { |
michael@0 | 78 | return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | static bool PseudoElementSupportsStyleAttribute(const Type aType) { |
michael@0 | 82 | MOZ_ASSERT(aType < ePseudo_PseudoElementCount); |
michael@0 | 83 | return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | static bool PseudoElementSupportsUserActionState(const Type aType); |
michael@0 | 87 | |
michael@0 | 88 | static bool PseudoElementIsChromeOnly(const Type aType) { |
michael@0 | 89 | MOZ_ASSERT(aType < ePseudo_PseudoElementCount); |
michael@0 | 90 | return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | private: |
michael@0 | 94 | static uint32_t FlagsForPseudoElement(const Type aType); |
michael@0 | 95 | |
michael@0 | 96 | // Does the given pseudo-element have all of the flags given? |
michael@0 | 97 | static bool PseudoElementHasFlags(const Type aType, uint32_t aFlags) |
michael@0 | 98 | { |
michael@0 | 99 | return (FlagsForPseudoElement(aType) & aFlags) == aFlags; |
michael@0 | 100 | } |
michael@0 | 101 | }; |
michael@0 | 102 | |
michael@0 | 103 | #endif /* nsCSSPseudoElements_h___ */ |