layout/style/nsCSSPseudoElements.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/nsCSSPseudoElements.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* atom list for CSS pseudo-elements */
    1.10 +
    1.11 +#ifndef nsCSSPseudoElements_h___
    1.12 +#define nsCSSPseudoElements_h___
    1.13 +
    1.14 +#include "nsIAtom.h"
    1.15 +
    1.16 +// Is this pseudo-element a CSS2 pseudo-element that can be specified
    1.17 +// with the single colon syntax (in addition to the double-colon syntax,
    1.18 +// which can be used for all pseudo-elements)?
    1.19 +#define CSS_PSEUDO_ELEMENT_IS_CSS2                     (1<<0)
    1.20 +// Is this pseudo-element a pseudo-element that can contain other
    1.21 +// elements?
    1.22 +// (Currently pseudo-elements are either leaves of the tree (relative to
    1.23 +// real elements) or they contain other elements in a non-tree-like
    1.24 +// manner (i.e., like incorrectly-nested start and end tags).  It's
    1.25 +// possible that in the future there might be container pseudo-elements
    1.26 +// that form a properly nested tree structure.  If that happens, we
    1.27 +// should probably split this flag into two.)
    1.28 +#define CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS           (1<<1)
    1.29 +// Flag to add the ability to take into account style attribute set for the
    1.30 +// pseudo element (by default it's ignored).
    1.31 +#define CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE    (1<<2)
    1.32 +// Flag that indicate the pseudo-element supports a user action pseudo-class
    1.33 +// following it, such as :active or :hover.  This would normally correspond
    1.34 +// to whether the pseudo-element is tree-like, but we don't support these
    1.35 +// pseudo-classes on ::before and ::after generated content yet.  See
    1.36 +// http://dev.w3.org/csswg/selectors4/#pseudo-elements.
    1.37 +#define CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE  (1<<3)
    1.38 +// Is content prevented from parsing selectors containing this pseudo-element?
    1.39 +#define CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY              (1<<4)
    1.40 +
    1.41 +// Empty class derived from nsIAtom so that function signatures can
    1.42 +// require an atom from this atom list.
    1.43 +class nsICSSPseudoElement : public nsIAtom {};
    1.44 +
    1.45 +class nsCSSPseudoElements {
    1.46 +public:
    1.47 +
    1.48 +  static void AddRefAtoms();
    1.49 +
    1.50 +  static bool IsPseudoElement(nsIAtom *aAtom);
    1.51 +
    1.52 +  static bool IsCSS2PseudoElement(nsIAtom *aAtom);
    1.53 +
    1.54 +#define CSS_PSEUDO_ELEMENT(_name, _value, _flags) \
    1.55 +  static nsICSSPseudoElement* _name;
    1.56 +#include "nsCSSPseudoElementList.h"
    1.57 +#undef CSS_PSEUDO_ELEMENT
    1.58 +
    1.59 +  enum Type {
    1.60 +    // If the actual pseudo-elements stop being first here, change
    1.61 +    // GetPseudoType.
    1.62 +#define CSS_PSEUDO_ELEMENT(_name, _value_, _flags) \
    1.63 +    ePseudo_##_name,
    1.64 +#include "nsCSSPseudoElementList.h"
    1.65 +#undef CSS_PSEUDO_ELEMENT
    1.66 +    ePseudo_PseudoElementCount,
    1.67 +    ePseudo_AnonBox = ePseudo_PseudoElementCount,
    1.68 +#ifdef MOZ_XUL
    1.69 +    ePseudo_XULTree,
    1.70 +#endif
    1.71 +    ePseudo_NotPseudoElement,
    1.72 +    ePseudo_MAX
    1.73 +  };
    1.74 +
    1.75 +  static Type GetPseudoType(nsIAtom* aAtom);
    1.76 +
    1.77 +  // Get the atom for a given Type.  aType must be < ePseudo_PseudoElementCount
    1.78 +  static nsIAtom* GetPseudoAtom(Type aType);
    1.79 +
    1.80 +  static bool PseudoElementContainsElements(const Type aType) {
    1.81 +    return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS);
    1.82 +  }
    1.83 +
    1.84 +  static bool PseudoElementSupportsStyleAttribute(const Type aType) {
    1.85 +    MOZ_ASSERT(aType < ePseudo_PseudoElementCount);
    1.86 +    return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE);
    1.87 +  }
    1.88 +
    1.89 +  static bool PseudoElementSupportsUserActionState(const Type aType);
    1.90 +
    1.91 +  static bool PseudoElementIsChromeOnly(const Type aType) {
    1.92 +    MOZ_ASSERT(aType < ePseudo_PseudoElementCount);
    1.93 +    return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY);
    1.94 +  }
    1.95 +
    1.96 +private:
    1.97 +  static uint32_t FlagsForPseudoElement(const Type aType);
    1.98 +
    1.99 +  // Does the given pseudo-element have all of the flags given?
   1.100 +  static bool PseudoElementHasFlags(const Type aType, uint32_t aFlags)
   1.101 +  {
   1.102 +    return (FlagsForPseudoElement(aType) & aFlags) == aFlags;
   1.103 +  }
   1.104 +};
   1.105 +
   1.106 +#endif /* nsCSSPseudoElements_h___ */

mercurial