Bug 1449089 - Remove CSSPseudoClassAtoms. r=xidorn
With the old style system gone it's no longer needed.
The patch renames nsCSSPseudoClasses::RegisterStaticAtoms() as
InitializePrefs() because that's all that function does now.
MozReview-Commit-ID: X2BTofFx1V
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -139,24 +139,24 @@ nsLayoutStatics::Initialize()
nsresult rv;
ContentParent::StartUp();
// Register static atoms. Note that nsGkAtoms must be initialized earlier
// than here, so it's done in NS_InitAtomTable() instead.
nsCSSAnonBoxes::RegisterStaticAtoms();
- nsCSSPseudoClasses::RegisterStaticAtoms();
nsCSSPseudoElements::RegisterStaticAtoms();
+ NS_SetStaticAtomsDone();
+
+ nsCSSPseudoClasses::InitializePrefs();
nsCSSKeywords::AddRefTable();
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
- NS_SetStaticAtomsDone();
-
StartupJSEnvironment();
nsGlobalWindowInner::Init();
nsGlobalWindowOuter::Init();
Navigator::Init();
nsXBLService::Init();
rv = nsContentUtils::Init();
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -996,19 +996,20 @@ GetStatesForPseudoClass(const nsAString&
// index out of bounds into this array no matter what.
EventStates(),
EventStates()
};
static_assert(MOZ_ARRAY_LENGTH(sPseudoClassStates) ==
static_cast<size_t>(CSSPseudoClassType::MAX),
"Length of PseudoClassStates array is incorrect");
- RefPtr<nsAtom> atom = NS_Atomize(aStatePseudo);
- CSSPseudoClassType type = nsCSSPseudoClasses::
- GetPseudoType(atom, CSSEnabledState::eIgnoreEnabledState);
+ // njn: we need to map a aStatePseudo (an nsAString) to a CSSPseudoClassType.
+ // Xidorn says that NonTSPseudoClass::state_flag can do it; it just needs to
+ // be exposed to Gecko.
+ CSSPseudoClassType type = CSSPseudoClassType::NotPseudo; // njn: temp
// Ignore :any-link so we don't give the element simultaneous
// visited and unvisited style state
if (type == CSSPseudoClassType::anyLink ||
type == CSSPseudoClassType::mozAnyLink) {
return EventStates();
}
// Our array above is long enough that indexing into it with
--- a/layout/style/nsCSSPseudoClassList.h
+++ b/layout/style/nsCSSPseudoClassList.h
@@ -1,37 +1,38 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
-/* atom list for CSS pseudo-classes */
+/* List of CSS pseudo-classes */
/*
- * This file contains the list of nsAtoms and their values for CSS
- * pseudo-classes. It is designed to be used as inline input to
- * nsCSSPseudoClasses.cpp *only* through the magic of C preprocessing.
- * All entries must be enclosed in the macros CSS_PSEUDO_CLASS,
- * CSS_STATE_DEPENDENT_PSEUDO_CLASS, or CSS_STATE_PSEUDO_CLASS which
- * will have cruel and unusual things done to them. The entries should
- * be kept in some sort of logical order. The common arguments to these
- * macros are:
- * name_ : The C++ identifier used for the atom (which will be a member
- * of nsCSSPseudoClasses)
- * value_ : The pseudo-class as a string, including the initial colon,
- * used as the string value of the atom.
+ * This file contains the list of CSS pseudo-classes. It is designed to be
+ * used as inline input to nsCSSPseudoClasses.cpp *only* through the magic of C
+ * preprocessing. All entries must be enclosed in the macros CSS_PSEUDO_CLASS,
+ * CSS_STATE_DEPENDENT_PSEUDO_CLASS, or CSS_STATE_PSEUDO_CLASS which will have
+ * cruel and unusual things done to them. The entries should be kept in some
+ * sort of logical order.
+ *
+ * The common arguments to these macros are:
+ * name_ : The C++ identifier used for the pseudo-class (used in various ways)
+ * value_ : The pseudo-class as a string, including the initial colon.
+ * (This is no longer used, but is useful documentation.)
* flags_ : A bitfield containing flags defined in nsCSSPseudoClasses.h
* pref_ : The name of the preference controlling whether the
* pseudo-class is recognized by the parser, or the empty
* string if it's unconditional.
+ *
* CSS_STATE_PSEUDO_CLASS has an additional argument:
* bit_ : The event state bit or bits that corresponds to the
* pseudo-class, i.e., causes it to match (only one bit
* required to match).
+ *
* CSS_STATE_DEPENDENT_PSEUDO_CLASS has an additional argument:
* bit_ : The event state bits that affect whether the pseudo-class
* matches. Matching depends on a customized per-class
* algorithm which should be defined in SelectorMatches() in
* nsCSSRuleProcessor.cpp.
*
* If CSS_STATE_PSEUDO_CLASS is not defined, it'll be automatically
* defined to CSS_STATE_DEPENDENT_PSEUDO_CLASS;
--- a/layout/style/nsCSSPseudoClasses.cpp
+++ b/layout/style/nsCSSPseudoClasses.cpp
@@ -23,73 +23,45 @@ using namespace mozilla;
#define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
static_assert(!((flags_) & CSS_PSEUDO_CLASS_ENABLED_IN_CHROME) || \
((flags_) & CSS_PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), \
"Pseudo-class '" #name_ "' is enabled in chrome, so it " \
"should also be enabled in UA sheets");
#include "nsCSSPseudoClassList.h"
#undef CSS_PSEUDO_CLASS
-class CSSPseudoClassAtoms
-{
-public:
- #define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
- NS_STATIC_ATOM_DECL(name_)
- #include "nsCSSPseudoClassList.h"
- #undef CSS_PSEUDO_CLASS
-};
-
-#define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
- NS_STATIC_ATOM_DEFN(CSSPseudoClassAtoms, name_)
-#include "nsCSSPseudoClassList.h"
-#undef CSS_PSEUDO_CLASS
-
-#define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
- NS_STATIC_ATOM_BUFFER(name_, value_)
-#include "nsCSSPseudoClassList.h"
-#undef CSS_PSEUDO_CLASS
-
-static const nsStaticAtomSetup sCSSPseudoClassAtomSetup[] = {
- #define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
- NS_STATIC_ATOM_SETUP(CSSPseudoClassAtoms, name_)
- #include "nsCSSPseudoClassList.h"
- #undef CSS_PSEUDO_CLASS
-};
-
// Flags data for each of the pseudo-classes, which must be separate
// from the previous array since there's no place for it in
// nsStaticAtomSetup.
/* static */ const uint32_t
nsCSSPseudoClasses::kPseudoClassFlags[] = {
#define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
flags_,
#include "nsCSSPseudoClassList.h"
#undef CSS_PSEUDO_CLASS
};
/* static */ bool
nsCSSPseudoClasses::sPseudoClassEnabled[] = {
// If the pseudo class has any "ENABLED_IN" flag set, it is disabled by
// default. Note that, if a pseudo class has pref, whatever its default value
- // is, it'll later be changed in nsCSSPseudoClasses::RegisterStaticAtoms() If
+ // is, it'll later be changed in nsCSSPseudoClasses::InitializePrefs() If
// the pseudo class has "ENABLED_IN" flags but doesn't have a pref, it is an
// internal pseudo class which is disabled elsewhere.
#define IS_ENABLED_BY_DEFAULT(flags_) \
(!((flags_) & CSS_PSEUDO_CLASS_ENABLED_MASK))
#define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
IS_ENABLED_BY_DEFAULT(flags_),
#include "nsCSSPseudoClassList.h"
#undef CSS_PSEUDO_CLASS
#undef IS_ENABLED_BY_DEFAULT
};
-void nsCSSPseudoClasses::RegisterStaticAtoms()
+void nsCSSPseudoClasses::InitializePrefs()
{
- NS_RegisterStaticAtoms(sCSSPseudoClassAtomSetup);
-
#define CSS_PSEUDO_CLASS(name_, value_, flags_, pref_) \
if (pref_[0]) { \
auto idx = static_cast<CSSPseudoElementTypeBase>(Type::name_); \
Preferences::AddBoolVarCache(&sPseudoClassEnabled[idx], pref_); \
}
#include "nsCSSPseudoClassList.h"
#undef CSS_PSEUDO_CLASS
}
@@ -106,38 +78,16 @@ bool
nsCSSPseudoClasses::HasNthPairArg(Type aType)
{
return aType == Type::nthChild ||
aType == Type::nthLastChild ||
aType == Type::nthOfType ||
aType == Type::nthLastOfType;
}
-void
-nsCSSPseudoClasses::PseudoTypeToString(Type aType, nsAString& aString)
-{
- MOZ_ASSERT(aType < Type::Count, "Unexpected type");
- auto idx = static_cast<CSSPseudoClassTypeBase>(aType);
- (*sCSSPseudoClassAtomSetup[idx].mAtomp)->ToString(aString);
-}
-
-/* static */ CSSPseudoClassType
-nsCSSPseudoClasses::GetPseudoType(nsAtom* aAtom, EnabledState aEnabledState)
-{
- Maybe<uint32_t> index =
- nsStaticAtomUtils::Lookup(aAtom, sCSSPseudoClassAtomSetup);
- if (index.isSome()) {
- Type type = Type(*index);
- if (IsEnabled(type, aEnabledState)) {
- return type;
- }
- }
- return Type::NotPseudo;
-}
-
/* static */ bool
nsCSSPseudoClasses::IsUserActionPseudoClass(Type aType)
{
// See http://dev.w3.org/csswg/selectors4/#useraction-pseudos
return aType == Type::hover ||
aType == Type::active ||
aType == Type::focus;
}
--- a/layout/style/nsCSSPseudoClasses.h
+++ b/layout/style/nsCSSPseudoClasses.h
@@ -54,29 +54,25 @@ enum class CSSPseudoClassType : CSSPseud
} // namespace mozilla
class nsCSSPseudoClasses
{
typedef mozilla::CSSPseudoClassType Type;
typedef mozilla::CSSEnabledState EnabledState;
public:
- static void RegisterStaticAtoms();
+ static void InitializePrefs();
- static Type GetPseudoType(nsAtom* aAtom, EnabledState aEnabledState);
static bool HasStringArg(Type aType);
static bool HasNthPairArg(Type aType);
static bool HasSelectorListArg(Type aType) {
return aType == Type::any;
}
static bool IsUserActionPseudoClass(Type aType);
- // Should only be used on types other than Count and NotPseudoClass
- static void PseudoTypeToString(Type aType, nsAString& aString);
-
static bool IsEnabled(Type aType, EnabledState aEnabledState)
{
auto index = static_cast<size_t>(aType);
MOZ_ASSERT(index < static_cast<size_t>(Type::Count));
if (sPseudoClassEnabled[index] ||
aEnabledState == EnabledState::eIgnoreEnabledState) {
return true;
}