2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/* atom list for CSS anonymous boxes */
|
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2018-08-15 08:46:39 +03:00
|
|
|
#include "nsGkAtomConsts.h"
|
2018-08-15 08:46:42 +03:00
|
|
|
#include "nsStaticAtomUtils.h"
|
1998-12-11 05:51:05 +03:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2018-08-15 08:46:39 +03:00
|
|
|
static nsStaticAtom* GetAtomBase() {
|
|
|
|
return const_cast<nsStaticAtom*>(
|
|
|
|
nsGkAtoms::GetAtomByIndex(kAtomIndex_AnonBoxes));
|
1998-12-11 05:51:05 +03:00
|
|
|
}
|
|
|
|
|
2018-08-15 08:46:39 +03:00
|
|
|
bool nsCSSAnonBoxes::IsAnonBox(nsAtom* aAtom) {
|
|
|
|
return nsStaticAtomUtils::IsMember(aAtom, GetAtomBase(),
|
|
|
|
kAtomCount_AnonBoxes);
|
2002-11-17 18:37:56 +03:00
|
|
|
}
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
#ifdef MOZ_XUL
|
2017-10-03 01:05:19 +03:00
|
|
|
/* static */ bool nsCSSAnonBoxes::IsTreePseudoElement(nsAtom* aPseudo) {
|
2017-04-26 18:54:43 +03:00
|
|
|
MOZ_ASSERT(nsCSSAnonBoxes::IsAnonBox(aPseudo));
|
2010-03-08 18:45:00 +03:00
|
|
|
return StringBeginsWith(nsDependentAtomString(aPseudo),
|
|
|
|
NS_LITERAL_STRING(":-moz-tree-"));
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
#endif
|
2017-03-08 08:18:39 +03:00
|
|
|
|
2017-03-09 07:39:47 +03:00
|
|
|
/* static*/ nsCSSAnonBoxes::NonInheriting
|
2017-10-03 01:05:19 +03:00
|
|
|
nsCSSAnonBoxes::NonInheritingTypeForPseudoTag(nsAtom* aPseudo) {
|
2017-03-09 07:39:47 +03:00
|
|
|
MOZ_ASSERT(IsNonInheritingAnonBox(aPseudo));
|
2018-08-15 08:46:39 +03:00
|
|
|
Maybe<uint32_t> index =
|
|
|
|
nsStaticAtomUtils::Lookup(aPseudo, GetAtomBase(), kAtomCount_AnonBoxes);
|
2018-03-20 05:01:28 +03:00
|
|
|
MOZ_RELEASE_ASSERT(index.isSome());
|
|
|
|
return static_cast<NonInheriting>(*index);
|
2017-03-09 07:39:47 +03:00
|
|
|
}
|
2018-08-15 08:46:39 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */ void nsCSSAnonBoxes::AssertAtoms() {
|
|
|
|
nsStaticAtom* base = GetAtomBase();
|
|
|
|
size_t index = 0;
|
|
|
|
#define CSS_ANON_BOX(name_, value_) \
|
|
|
|
{ \
|
|
|
|
RefPtr<nsAtom> atom = NS_Atomize(value_); \
|
|
|
|
MOZ_ASSERT(atom == nsGkAtoms::AnonBox_##name_, \
|
|
|
|
"Static atom for " #name_ " has incorrect value"); \
|
|
|
|
MOZ_ASSERT(atom == &base[index], \
|
|
|
|
"Static atom for " #name_ " not at expected index"); \
|
|
|
|
++index; \
|
|
|
|
}
|
|
|
|
#include "nsCSSAnonBoxList.h"
|
|
|
|
#undef CSS_ANON_BOX
|
|
|
|
}
|
|
|
|
#endif
|