Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/style/nsCSSAnonBoxes.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/* atom list for CSS anonymous boxes */
8
9
#include "mozilla/ArrayUtils.h"
10
11
#include "nsCSSAnonBoxes.h"
12
#include "nsGkAtomConsts.h"
13
#include "nsStaticAtomUtils.h"
14
15
using namespace mozilla;
16
17
static nsStaticAtom*
18
GetAtomBase()
19
0
{
20
0
  return const_cast<nsStaticAtom*>(
21
0
      nsGkAtoms::GetAtomByIndex(kAtomIndex_AnonBoxes));
22
0
}
23
24
bool
25
nsCSSAnonBoxes::IsAnonBox(nsAtom* aAtom)
26
0
{
27
0
  return nsStaticAtomUtils::IsMember(aAtom, GetAtomBase(),
28
0
                                     kAtomCount_AnonBoxes);
29
0
}
30
31
#ifdef MOZ_XUL
32
/* static */ bool
33
nsCSSAnonBoxes::IsTreePseudoElement(nsAtom* aPseudo)
34
0
{
35
0
  MOZ_ASSERT(nsCSSAnonBoxes::IsAnonBox(aPseudo));
36
0
  return StringBeginsWith(nsDependentAtomString(aPseudo),
37
0
                          NS_LITERAL_STRING(":-moz-tree-"));
38
0
}
39
#endif
40
41
/* static*/ nsCSSAnonBoxes::NonInheriting
42
nsCSSAnonBoxes::NonInheritingTypeForPseudoTag(nsAtom* aPseudo)
43
0
{
44
0
  MOZ_ASSERT(IsNonInheritingAnonBox(aPseudo));
45
0
  Maybe<uint32_t> index =
46
0
    nsStaticAtomUtils::Lookup(aPseudo, GetAtomBase(), kAtomCount_AnonBoxes);
47
0
  MOZ_RELEASE_ASSERT(index.isSome());
48
0
  return static_cast<NonInheriting>(*index);
49
0
}
50
51
#ifdef DEBUG
52
/* static */ void
53
nsCSSAnonBoxes::AssertAtoms()
54
{
55
  nsStaticAtom* base = GetAtomBase();
56
  size_t index = 0;
57
#define CSS_ANON_BOX(name_, value_)                                  \
58
  {                                                                  \
59
    RefPtr<nsAtom> atom = NS_Atomize(value_);                        \
60
    MOZ_ASSERT(atom == nsGkAtoms::AnonBox_##name_,                   \
61
               "Static atom for " #name_ " has incorrect value");    \
62
    MOZ_ASSERT(atom == &base[index],                                 \
63
               "Static atom for " #name_ " not at expected index");  \
64
    ++index;                                                         \
65
  }
66
#include "nsCSSAnonBoxList.h"
67
#undef CSS_ANON_BOX
68
}
69
#endif