2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* atom list for CSS pseudo-classes */
|
|
|
|
|
2011-10-10 22:50:08 -07:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCSSPseudoClasses.h"
|
|
|
|
#include "nsAtomListUtils.h"
|
|
|
|
#include "nsStaticAtom.h"
|
|
|
|
#include "nsMemory.h"
|
|
|
|
|
2011-10-10 22:50:08 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// define storage for all atoms
|
2011-03-23 06:52:25 -07:00
|
|
|
#define CSS_PSEUDO_CLASS(_name, _value) static nsIAtom* sPseudoClass_##_name;
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
|
2010-03-08 07:44:59 -08:00
|
|
|
#define CSS_PSEUDO_CLASS(name_, value_) \
|
|
|
|
NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
|
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static const nsStaticAtom CSSPseudoClasses_info[] = {
|
|
|
|
#define CSS_PSEUDO_CLASS(name_, value_) \
|
2011-03-23 06:52:25 -07:00
|
|
|
NS_STATIC_ATOM(name_##_buffer, &sPseudoClass_##name_),
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCSSPseudoClassList.h"
|
|
|
|
#undef CSS_PSEUDO_CLASS
|
|
|
|
};
|
|
|
|
|
|
|
|
void nsCSSPseudoClasses::AddRefAtoms()
|
|
|
|
{
|
2012-03-08 18:22:57 -08:00
|
|
|
NS_RegisterStaticAtoms(CSSPseudoClasses_info);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-03-23 06:52:24 -07:00
|
|
|
nsCSSPseudoClasses::HasStringArg(Type aType)
|
2008-06-02 20:17:35 -07:00
|
|
|
{
|
2011-03-23 06:52:24 -07:00
|
|
|
return aType == ePseudoClass_lang ||
|
|
|
|
aType == ePseudoClass_mozEmptyExceptChildrenWithLocalname ||
|
|
|
|
aType == ePseudoClass_mozSystemMetric ||
|
2012-08-09 20:37:58 -07:00
|
|
|
aType == ePseudoClass_mozLocaleDir ||
|
|
|
|
aType == ePseudoClass_dir;
|
2008-06-02 20:17:35 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-03-23 06:52:24 -07:00
|
|
|
nsCSSPseudoClasses::HasNthPairArg(Type aType)
|
2008-06-02 20:17:35 -07:00
|
|
|
{
|
2011-03-23 06:52:24 -07:00
|
|
|
return aType == ePseudoClass_nthChild ||
|
|
|
|
aType == ePseudoClass_nthLastChild ||
|
|
|
|
aType == ePseudoClass_nthOfType ||
|
|
|
|
aType == ePseudoClass_nthLastOfType;
|
2010-04-23 19:59:47 -07:00
|
|
|
}
|
|
|
|
|
2011-03-23 06:52:25 -07: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-10 23:37:41 -08:00
|
|
|
nsCSSPseudoClasses::Type
|
|
|
|
nsCSSPseudoClasses::GetPseudoType(nsIAtom* aAtom)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(CSSPseudoClasses_info); ++i) {
|
2009-12-10 23:37:41 -08:00
|
|
|
if (*CSSPseudoClasses_info[i].mAtom == aAtom) {
|
|
|
|
return Type(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsCSSPseudoClasses::ePseudoClass_NotPseudoClass;
|
|
|
|
}
|