2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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 05:47:31 +00:00
|
|
|
|
|
|
|
/* atom list for CSS pseudo-classes */
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSPseudoClasses.h"
|
2003-04-02 04:51:07 +00:00
|
|
|
#include "nsStaticAtom.h"
|
2012-12-25 03:35:34 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
1998-12-11 02:51:05 +00:00
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
1999-07-18 00:24:47 +00:00
|
|
|
// define storage for all atoms
|
2012-12-25 03:35:34 +00:00
|
|
|
#define CSS_PSEUDO_CLASS(_name, _value, _pref) \
|
|
|
|
static nsIAtom* sPseudoClass_##_name;
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
1998-12-11 02:51:05 +00:00
|
|
|
|
2012-12-25 03:35:34 +00:00
|
|
|
#define CSS_PSEUDO_CLASS(name_, value_, pref_) \
|
2010-03-08 15:44:59 +00:00
|
|
|
NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
|
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
|
2003-04-02 04:51:07 +00:00
|
|
|
static const nsStaticAtom CSSPseudoClasses_info[] = {
|
2012-12-25 03:35:34 +00:00
|
|
|
#define CSS_PSEUDO_CLASS(name_, value_, pref_) \
|
2011-03-23 13:52:25 +00:00
|
|
|
NS_STATIC_ATOM(name_##_buffer, &sPseudoClass_##name_),
|
2003-02-22 15:58:07 +00:00
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
};
|
|
|
|
|
2012-12-25 03:35:34 +00:00
|
|
|
static bool sPseudoClassEnabled[] = {
|
|
|
|
#define CSS_PSEUDO_CLASS(name_, value_, pref_) \
|
|
|
|
true,
|
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
};
|
|
|
|
|
2002-11-17 15:37:56 +00:00
|
|
|
void nsCSSPseudoClasses::AddRefAtoms()
|
1998-12-11 02:51:05 +00:00
|
|
|
{
|
2012-03-09 02:22:57 +00:00
|
|
|
NS_RegisterStaticAtoms(CSSPseudoClasses_info);
|
2012-12-25 03:35:34 +00:00
|
|
|
|
|
|
|
#define CSS_PSEUDO_CLASS(name_, value_, pref_) \
|
|
|
|
if (pref_[0]) { \
|
|
|
|
Preferences::AddBoolVarCache(&sPseudoClassEnabled[ePseudoClass_##name_], \
|
|
|
|
pref_); \
|
|
|
|
}
|
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
1998-12-11 02:51:05 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-03-23 13:52:24 +00:00
|
|
|
nsCSSPseudoClasses::HasStringArg(Type aType)
|
2008-06-03 03:17:35 +00:00
|
|
|
{
|
2011-03-23 13:52:24 +00:00
|
|
|
return aType == ePseudoClass_lang ||
|
|
|
|
aType == ePseudoClass_mozEmptyExceptChildrenWithLocalname ||
|
|
|
|
aType == ePseudoClass_mozSystemMetric ||
|
2012-08-10 03:37:58 +00:00
|
|
|
aType == ePseudoClass_mozLocaleDir ||
|
|
|
|
aType == ePseudoClass_dir;
|
2008-06-03 03:17:35 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-03-23 13:52:24 +00:00
|
|
|
nsCSSPseudoClasses::HasNthPairArg(Type aType)
|
2008-06-03 03:17:35 +00:00
|
|
|
{
|
2011-03-23 13:52:24 +00:00
|
|
|
return aType == ePseudoClass_nthChild ||
|
|
|
|
aType == ePseudoClass_nthLastChild ||
|
|
|
|
aType == ePseudoClass_nthOfType ||
|
|
|
|
aType == ePseudoClass_nthLastOfType;
|
2010-04-24 02:59:47 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 13:52:25 +00:00
|
|
|
void
|
|
|
|
nsCSSPseudoClasses::PseudoTypeToString(Type aType, nsAString& aString)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aType < ePseudoClass_Count, "Unexpected type");
|
|
|
|
NS_ABORT_IF_FALSE(aType >= 0, "Very unexpected type");
|
|
|
|
(*CSSPseudoClasses_info[aType].mAtom)->ToString(aString);
|
|
|
|
}
|
|
|
|
|
2009-12-11 07:37:41 +00:00
|
|
|
nsCSSPseudoClasses::Type
|
|
|
|
nsCSSPseudoClasses::GetPseudoType(nsIAtom* aAtom)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(CSSPseudoClasses_info); ++i) {
|
2009-12-11 07:37:41 +00:00
|
|
|
if (*CSSPseudoClasses_info[i].mAtom == aAtom) {
|
2012-12-25 03:35:34 +00:00
|
|
|
return sPseudoClassEnabled[i] ? Type(i) : ePseudoClass_NotPseudoClass;
|
2009-12-11 07:37:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsCSSPseudoClasses::ePseudoClass_NotPseudoClass;
|
|
|
|
}
|