summaryrefslogtreecommitdiffstats
path: root/layout/style/nsCSSAnonBoxes.h
blob: 9226c8476685821cac03d69ee22e624d45177b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

/* atom list for CSS anonymous boxes */

#ifndef nsCSSAnonBoxes_h___
#define nsCSSAnonBoxes_h___

#include "nsAtom.h"
#include "nsGkAtoms.h"
#include "mozilla/PseudoStyleType.h"

class nsCSSAnonBoxes {
  using PseudoStyleType = mozilla::PseudoStyleType;
  using PseudoStyle = mozilla::PseudoStyle;

 public:
#ifdef MOZ_XUL
  static bool IsTreePseudoElement(nsAtom* aPseudo);
#endif
  static bool IsNonElement(PseudoStyleType aPseudo) {
    return aPseudo == PseudoStyleType::mozText ||
           aPseudo == PseudoStyleType::oofPlaceholder ||
           aPseudo == PseudoStyleType::firstLetterContinuation;
  }

  enum class NonInheriting : uint8_t {
#define CSS_ANON_BOX(_name, _value) /* nothing */
#define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name,
#include "nsCSSAnonBoxList.h"
#undef CSS_NON_INHERITING_ANON_BOX
#undef CSS_ANON_BOX
    _Count
  };

  // Get the NonInheriting type for a given pseudo tag.  The pseudo tag must
  // test true for IsNonInheritingAnonBox.
  static NonInheriting NonInheritingTypeForPseudoType(PseudoStyleType aType) {
    MOZ_ASSERT(PseudoStyle::IsNonInheritingAnonBox(aType));
    static_assert(sizeof(PseudoStyleType) == sizeof(uint8_t), "");
    return static_cast<NonInheriting>(
        static_cast<uint8_t>(aType) -
        static_cast<uint8_t>(PseudoStyleType::NonInheritingAnonBoxesStart));
  }

#ifdef DEBUG
  static nsStaticAtom* GetAtomBase();
  static void AssertAtoms();
#endif

// Alias nsCSSAnonBoxes::foo() to nsGkAtoms::AnonBox_foo.
#define CSS_ANON_BOX(name_, value_)                       \
  static nsCSSAnonBoxPseudoStaticAtom* name_() {          \
    return const_cast<nsCSSAnonBoxPseudoStaticAtom*>(     \
        static_cast<const nsCSSAnonBoxPseudoStaticAtom*>( \
            nsGkAtoms::AnonBox_##name_));                 \
  }
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
};

#endif /* nsCSSAnonBoxes_h___ */