2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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 pseudo-elements */
|
|
|
|
|
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 "nsCSSPseudoElements.h"
|
2003-02-22 18:58:07 +03:00
|
|
|
#include "nsAtomListUtils.h"
|
2003-04-02 08:51:07 +04:00
|
|
|
#include "nsStaticAtom.h"
|
2009-10-08 07:22:42 +04:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1998-12-11 05:51:05 +03:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
1999-07-18 04:24:47 +04:00
|
|
|
// define storage for all atoms
|
2009-08-11 02:52:29 +04:00
|
|
|
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
|
|
|
|
nsICSSPseudoElement* nsCSSPseudoElements::name_;
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSPseudoElementList.h"
|
|
|
|
#undef CSS_PSEUDO_ELEMENT
|
1998-12-11 05:51:05 +03:00
|
|
|
|
2010-03-08 18:44:59 +03:00
|
|
|
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
|
2013-11-15 06:42:57 +04:00
|
|
|
NS_STATIC_ATOM_BUFFER(name_##_pseudo_element_buffer, value_)
|
2010-03-08 18:44:59 +03:00
|
|
|
#include "nsCSSPseudoElementList.h"
|
2010-03-10 23:33:37 +03:00
|
|
|
#undef CSS_PSEUDO_ELEMENT
|
2010-03-08 18:44:59 +03:00
|
|
|
|
2014-10-23 20:57:27 +04:00
|
|
|
// Array of nsStaticAtom for each of the pseudo-elements.
|
2003-04-02 08:51:07 +04:00
|
|
|
static const nsStaticAtom CSSPseudoElements_info[] = {
|
2009-08-11 02:52:29 +04:00
|
|
|
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
|
2013-11-15 06:42:57 +04:00
|
|
|
NS_STATIC_ATOM(name_##_pseudo_element_buffer, (nsIAtom**)&nsCSSPseudoElements::name_),
|
2003-02-22 18:58:07 +03:00
|
|
|
#include "nsCSSPseudoElementList.h"
|
|
|
|
#undef CSS_PSEUDO_ELEMENT
|
|
|
|
};
|
|
|
|
|
2014-10-23 20:57:27 +04:00
|
|
|
// Flags data for each of the pseudo-elements, which must be separate
|
|
|
|
// from the previous array since there's no place for it in
|
|
|
|
// nsStaticAtom.
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint32_t CSSPseudoElements_flags[] = {
|
2009-08-11 02:52:29 +04:00
|
|
|
#define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
|
|
|
|
flags_,
|
|
|
|
#include "nsCSSPseudoElementList.h"
|
|
|
|
#undef CSS_PSEUDO_ELEMENT
|
|
|
|
};
|
|
|
|
|
2002-11-17 18:37:56 +03:00
|
|
|
void nsCSSPseudoElements::AddRefAtoms()
|
1998-12-11 05:51:05 +03:00
|
|
|
{
|
2012-03-09 06:22:57 +04:00
|
|
|
NS_RegisterStaticAtoms(CSSPseudoElements_info);
|
1998-12-11 05:51:05 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsCSSPseudoElements::IsPseudoElement(nsIAtom *aAtom)
|
2002-11-17 18:37:56 +03:00
|
|
|
{
|
2003-02-22 18:58:07 +03:00
|
|
|
return nsAtomListUtils::IsMember(aAtom, CSSPseudoElements_info,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(CSSPseudoElements_info));
|
2002-11-17 18:37:56 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/* static */ bool
|
2009-10-08 07:22:42 +04:00
|
|
|
nsCSSPseudoElements::IsCSS2PseudoElement(nsIAtom *aAtom)
|
|
|
|
{
|
|
|
|
// We don't implement this using PseudoElementHasFlags because callers
|
|
|
|
// want to pass things that could be anon boxes.
|
|
|
|
NS_ASSERTION(nsCSSPseudoElements::IsPseudoElement(aAtom) ||
|
|
|
|
nsCSSAnonBoxes::IsAnonBox(aAtom),
|
|
|
|
"must be pseudo element or anon box");
|
2011-09-29 10:19:26 +04:00
|
|
|
bool result = aAtom == nsCSSPseudoElements::after ||
|
2009-10-08 07:22:42 +04:00
|
|
|
aAtom == nsCSSPseudoElements::before ||
|
|
|
|
aAtom == nsCSSPseudoElements::firstLetter ||
|
|
|
|
aAtom == nsCSSPseudoElements::firstLine;
|
|
|
|
NS_ASSERTION(nsCSSAnonBoxes::IsAnonBox(aAtom) ||
|
|
|
|
result ==
|
2013-11-17 22:33:56 +04:00
|
|
|
PseudoElementHasFlags(GetPseudoType(aAtom), CSS_PSEUDO_ELEMENT_IS_CSS2),
|
2009-10-08 07:22:42 +04:00
|
|
|
"result doesn't match flags");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
/* static */ nsCSSPseudoElements::Type
|
|
|
|
nsCSSPseudoElements::GetPseudoType(nsIAtom *aAtom)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(CSSPseudoElements_info); ++i) {
|
2009-12-11 10:37:40 +03:00
|
|
|
if (*CSSPseudoElements_info[i].mAtom == aAtom) {
|
|
|
|
return Type(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCSSAnonBoxes::IsAnonBox(aAtom)) {
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (nsCSSAnonBoxes::IsTreePseudoElement(aAtom)) {
|
|
|
|
return ePseudo_XULTree;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ePseudo_AnonBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ePseudo_NotPseudoElement;
|
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
/* static */ nsIAtom*
|
|
|
|
nsCSSPseudoElements::GetPseudoAtom(Type aType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType < nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected type");
|
|
|
|
return *CSSPseudoElements_info[aType].mAtom;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
/* static */ uint32_t
|
2013-11-17 22:33:56 +04:00
|
|
|
nsCSSPseudoElements::FlagsForPseudoElement(const Type aType)
|
2003-07-04 05:33:10 +04:00
|
|
|
{
|
2013-11-17 22:33:56 +04:00
|
|
|
size_t index = static_cast<size_t>(aType);
|
|
|
|
NS_ASSERTION(index < ArrayLength(CSSPseudoElements_flags),
|
2009-08-11 02:52:29 +04:00
|
|
|
"argument must be a pseudo-element");
|
2013-11-17 22:33:56 +04:00
|
|
|
return CSSPseudoElements_flags[index];
|
2003-07-04 05:33:10 +04:00
|
|
|
}
|
2013-11-28 10:46:38 +04:00
|
|
|
|
|
|
|
/* static */ bool
|
|
|
|
nsCSSPseudoElements::PseudoElementSupportsUserActionState(const Type aType)
|
|
|
|
{
|
|
|
|
return PseudoElementHasFlags(aType,
|
|
|
|
CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE);
|
|
|
|
}
|