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.
|
2016-05-10 11:44:05 +03:00
|
|
|
/* static */ const uint32_t
|
|
|
|
nsCSSPseudoElements::kPseudoElementFlags[] = {
|
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) ||
|
2016-05-10 11:44:05 +03:00
|
|
|
result == PseudoElementHasFlags(
|
|
|
|
GetPseudoType(aAtom, EnabledState::eIgnoreEnabledState),
|
|
|
|
CSS_PSEUDO_ELEMENT_IS_CSS2),
|
2009-10-08 07:22:42 +04:00
|
|
|
"result doesn't match flags");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
/* static */ CSSPseudoElementType
|
2016-05-10 11:44:05 +03:00
|
|
|
nsCSSPseudoElements::GetPseudoType(nsIAtom *aAtom, EnabledState aEnabledState)
|
2009-12-11 10:37:40 +03:00
|
|
|
{
|
2016-02-18 21:18:00 +03:00
|
|
|
for (CSSPseudoElementTypeBase i = 0;
|
|
|
|
i < ArrayLength(CSSPseudoElements_info);
|
|
|
|
++i) {
|
2009-12-11 10:37:40 +03:00
|
|
|
if (*CSSPseudoElements_info[i].mAtom == aAtom) {
|
2016-05-10 11:44:05 +03:00
|
|
|
auto type = static_cast<Type>(i);
|
2016-09-08 02:38:38 +03:00
|
|
|
// ::moz-placeholder is an alias for ::placeholder
|
|
|
|
if (type == CSSPseudoElementType::mozPlaceholder) {
|
|
|
|
type = CSSPseudoElementType::placeholder;
|
|
|
|
}
|
2016-05-10 11:44:05 +03:00
|
|
|
return IsEnabled(type, aEnabledState) ? type : Type::NotPseudo;
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCSSAnonBoxes::IsAnonBox(aAtom)) {
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (nsCSSAnonBoxes::IsTreePseudoElement(aAtom)) {
|
2016-02-17 01:07:00 +03:00
|
|
|
return Type::XULTree;
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
return Type::AnonBox;
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
return Type::NotPseudo;
|
2009-12-11 10:37:40 +03:00
|
|
|
}
|
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
/* static */ nsIAtom*
|
|
|
|
nsCSSPseudoElements::GetPseudoAtom(Type aType)
|
|
|
|
{
|
2016-02-17 23:37:00 +03:00
|
|
|
NS_ASSERTION(aType < Type::Count, "Unexpected type");
|
2016-02-18 21:18:00 +03:00
|
|
|
return *CSSPseudoElements_info[
|
|
|
|
static_cast<CSSPseudoElementTypeBase>(aType)].mAtom;
|
2009-12-11 10:37:40 +03: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);
|
|
|
|
}
|