mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1244049 - Part 4: Define CSSPseudoElementTypeBase. r=dbaron
In order to convert CSSPseudoElementType into its underlying type easier, we define CSSPseudoElementTypeBase. However, keep using uint8_t directly for forward declarations.
This commit is contained in:
parent
65a7e5077d
commit
5c37ed6ba0
@ -49,6 +49,8 @@ public:
|
||||
return 0;
|
||||
|
||||
// Convert the scoped enum into an integer while adding it to hash.
|
||||
// Note: CSSPseudoElementTypeBase is uint8_t, so we convert it into
|
||||
// uint8_t directly to avoid including the header.
|
||||
return mozilla::HashGeneric(aKey->mElement,
|
||||
static_cast<uint8_t>(aKey->mPseudoType));
|
||||
}
|
||||
|
@ -1194,8 +1194,9 @@ inDOMUtils::GetCSSPseudoElementNames(uint32_t* aLength, char16_t*** aNames)
|
||||
{
|
||||
nsTArray<nsIAtom*> array;
|
||||
|
||||
const uint8_t pseudoCount = static_cast<uint8_t>(CSSPseudoElementType::Count);
|
||||
for (uint8_t i = 0; i < pseudoCount; ++i) {
|
||||
const CSSPseudoElementTypeBase pseudoCount =
|
||||
static_cast<CSSPseudoElementTypeBase>(CSSPseudoElementType::Count);
|
||||
for (CSSPseudoElementTypeBase i = 0; i < pseudoCount; ++i) {
|
||||
CSSPseudoElementType type = static_cast<CSSPseudoElementType>(i);
|
||||
if (!nsCSSPseudoElements::PseudoElementIsUASheetOnly(type)) {
|
||||
nsIAtom* atom = nsCSSPseudoElements::GetPseudoAtom(type);
|
||||
|
@ -76,7 +76,9 @@ nsCSSPseudoElements::IsCSS2PseudoElement(nsIAtom *aAtom)
|
||||
/* static */ CSSPseudoElementType
|
||||
nsCSSPseudoElements::GetPseudoType(nsIAtom *aAtom)
|
||||
{
|
||||
for (uint8_t i = 0; i < ArrayLength(CSSPseudoElements_info); ++i) {
|
||||
for (CSSPseudoElementTypeBase i = 0;
|
||||
i < ArrayLength(CSSPseudoElements_info);
|
||||
++i) {
|
||||
if (*CSSPseudoElements_info[i].mAtom == aAtom) {
|
||||
return static_cast<Type>(i);
|
||||
}
|
||||
@ -99,13 +101,14 @@ nsCSSPseudoElements::GetPseudoType(nsIAtom *aAtom)
|
||||
nsCSSPseudoElements::GetPseudoAtom(Type aType)
|
||||
{
|
||||
NS_ASSERTION(aType < Type::Count, "Unexpected type");
|
||||
return *CSSPseudoElements_info[static_cast<uint8_t>(aType)].mAtom;
|
||||
return *CSSPseudoElements_info[
|
||||
static_cast<CSSPseudoElementTypeBase>(aType)].mAtom;
|
||||
}
|
||||
|
||||
/* static */ uint32_t
|
||||
nsCSSPseudoElements::FlagsForPseudoElement(const Type aType)
|
||||
{
|
||||
uint8_t index = static_cast<uint8_t>(aType);
|
||||
CSSPseudoElementTypeBase index = static_cast<CSSPseudoElementTypeBase>(aType);
|
||||
NS_ASSERTION(index < ArrayLength(CSSPseudoElements_flags),
|
||||
"argument must be a pseudo-element");
|
||||
return CSSPseudoElements_flags[index];
|
||||
|
@ -39,7 +39,8 @@ namespace mozilla {
|
||||
|
||||
// The total count of CSSPseudoElement is less than 256,
|
||||
// so use uint8_t as its underlying type.
|
||||
enum class CSSPseudoElementType : uint8_t {
|
||||
typedef uint8_t CSSPseudoElementTypeBase;
|
||||
enum class CSSPseudoElementType : CSSPseudoElementTypeBase {
|
||||
// If the actual pseudo-elements stop being first here, change
|
||||
// GetPseudoType.
|
||||
#define CSS_PSEUDO_ELEMENT(_name, _value_, _flags) \
|
||||
|
@ -910,8 +910,8 @@ struct RuleCascadeData {
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
RuleHash mRuleHash;
|
||||
RuleHash*
|
||||
mPseudoElementRuleHashes[static_cast<uint8_t>(CSSPseudoElementType::Count)];
|
||||
RuleHash* mPseudoElementRuleHashes[
|
||||
static_cast<CSSPseudoElementTypeBase>(CSSPseudoElementType::Count)];
|
||||
nsTArray<nsCSSRuleProcessor::StateSelector> mStateSelectors;
|
||||
EventStates mSelectorDocumentStates;
|
||||
PLDHashTable mClassSelectors;
|
||||
@ -2644,9 +2644,8 @@ nsCSSRuleProcessor::RulesMatching(PseudoElementRuleProcessorData* aData)
|
||||
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
|
||||
|
||||
if (cascade) {
|
||||
RuleHash* ruleHash =
|
||||
cascade->mPseudoElementRuleHashes[static_cast<uint8_t>(
|
||||
aData->mPseudoType)];
|
||||
RuleHash* ruleHash = cascade->mPseudoElementRuleHashes[
|
||||
static_cast<CSSPseudoElementTypeBase>(aData->mPseudoType)];
|
||||
if (ruleHash) {
|
||||
NodeMatchContext nodeContext(EventStates(),
|
||||
nsCSSRuleProcessor::IsLink(aData->mElement));
|
||||
@ -3415,8 +3414,8 @@ AddRule(RuleSelectorPair* aRuleInfo, RuleCascadeData* aCascade)
|
||||
if (MOZ_LIKELY(pseudoType == CSSPseudoElementType::NotPseudo)) {
|
||||
cascade->mRuleHash.AppendRule(*aRuleInfo);
|
||||
} else if (pseudoType < CSSPseudoElementType::Count) {
|
||||
RuleHash*& ruleHash =
|
||||
cascade->mPseudoElementRuleHashes[static_cast<uint8_t>(pseudoType)];
|
||||
RuleHash*& ruleHash = cascade->mPseudoElementRuleHashes[
|
||||
static_cast<CSSPseudoElementTypeBase>(pseudoType)];
|
||||
if (!ruleHash) {
|
||||
ruleHash = new RuleHash(cascade->mQuirksMode);
|
||||
if (!ruleHash) {
|
||||
|
@ -90,7 +90,8 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
|
||||
// This check has to be done "backward", because if it were written the
|
||||
// more natural way it wouldn't fail even when it needed to.
|
||||
static_assert((UINT64_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
|
||||
static_cast<uint8_t>(CSSPseudoElementType::MAX),
|
||||
static_cast<CSSPseudoElementTypeBase>(
|
||||
CSSPseudoElementType::MAX),
|
||||
"pseudo element bits no longer fit in a uint64_t");
|
||||
MOZ_ASSERT(aRuleNode);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user