Bug 972601, part 6 - Replace nsDFAState with uint32_t in nsXULTreeStyleCache. r=dbaron

It is now a pointless wrapper around uint32_t.
This commit is contained in:
Andrew McCreight 2014-05-09 09:49:54 -07:00
parent 281c5cb4e6
commit 6ef592947d
2 changed files with 12 additions and 35 deletions

View File

@ -7,7 +7,7 @@
#include "nsStyleSet.h"
#include "mozilla/dom/Element.h"
nsTreeStyleCache::Transition::Transition(uint32_t aState, nsIAtom* aSymbol)
nsTreeStyleCache::Transition::Transition(DFAState aState, nsIAtom* aSymbol)
: mState(aState), mInputSymbol(aSymbol)
{
}
@ -47,22 +47,22 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator,
// The first transition is always made off the supplied pseudo-element.
Transition transition(0, aPseudoElement);
nsDFAState* currState = mTransitionTable->Get(transition);
DFAState currState = mTransitionTable->Get(transition);
if (!currState) {
// We had a miss. Make a new state and add it to our hash.
currState = new nsDFAState(mNextState);
currState = mNextState;
mNextState++;
mTransitionTable->Put(transition, currState);
}
for (uint32_t i = 0; i < count; i++) {
Transition transition(currState->GetStateID(), aInputWord[i]);
Transition transition(currState, aInputWord[i]);
currState = mTransitionTable->Get(transition);
if (!currState) {
// We had a miss. Make a new state and add it to our hash.
currState = new nsDFAState(mNextState);
currState = mNextState;
mNextState++;
mTransitionTable->Put(transition, currState);
}
@ -72,7 +72,7 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator,
// Look up our style context for this state.
nsStyleContext* result = nullptr;
if (mCache) {
result = mCache->GetWeak(currState->GetStateID());
result = mCache->GetWeak(currState);
}
if (!result) {
// We missed the cache. Resolve this pseudo-style.
@ -85,7 +85,7 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator,
mCache = new StyleContextCache();
}
result = newResult.get();
mCache->Put(currState->GetStateID(), newResult.forget());
mCache->Put(currState, newResult.forget());
}
return result;

View File

@ -7,7 +7,6 @@
#define nsTreeStyleCache_h__
#include "mozilla/Attributes.h"
#include "nsHashtable.h"
#include "nsIAtom.h"
#include "nsCOMArray.h"
#include "nsICSSPseudoComparator.h"
@ -16,29 +15,6 @@
typedef nsCOMArray<nsIAtom> AtomArray;
class nsDFAState : public nsHashKey
{
public:
uint32_t mStateID;
nsDFAState(uint32_t aID) :mStateID(aID) {}
uint32_t GetStateID() { return mStateID; }
uint32_t HashCode(void) const MOZ_OVERRIDE {
return mStateID;
}
bool Equals(const nsHashKey *aKey) const MOZ_OVERRIDE {
nsDFAState* key = (nsDFAState*)aKey;
return key->mStateID == mStateID;
}
nsHashKey *Clone(void) const MOZ_OVERRIDE {
return new nsDFAState(mStateID);
}
};
class nsTreeStyleCache
{
public:
@ -67,20 +43,21 @@ public:
const AtomArray & aInputWord);
protected:
typedef uint32_t DFAState;
class Transition MOZ_FINAL
{
public:
Transition(uint32_t aState, nsIAtom* aSymbol);
Transition(DFAState aState, nsIAtom* aSymbol);
bool operator==(const Transition& aOther) const;
uint32_t Hash() const;
private:
uint32_t mState;
DFAState mState;
nsCOMPtr<nsIAtom> mInputSymbol;
};
typedef nsClassHashtable<nsGenericHashKey<Transition>, nsDFAState> TransitionTable;
typedef nsDataHashtable<nsGenericHashKey<Transition>, DFAState> TransitionTable;
// A transition table for a deterministic finite automaton. The DFA
// takes as its input a single pseudoelement and an ordered set of properties.
@ -105,7 +82,7 @@ protected:
// An integer counter that is used when we need to make new states in the
// DFA.
uint32_t mNextState;
DFAState mNextState;
};
#endif // nsTreeStyleCache_h__