Bug 1202512 - Part 1: Add Element flags to record whether an eRestyle_SomeDescendants restyle is pending for it. r=bzbarsky

This commit is contained in:
Cameron McCormack 2015-09-12 19:08:10 +10:00
parent afe78f9887
commit 65da2cda42
4 changed files with 41 additions and 16 deletions

View File

@ -89,18 +89,27 @@ enum {
// change will attempt to restyle descendants).
ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT = ELEMENT_FLAG_BIT(3),
// All of those bits together, for convenience.
ELEMENT_ALL_RESTYLE_FLAGS = ELEMENT_HAS_PENDING_RESTYLE |
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT |
ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE |
ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT,
// Set if this element has a pending restyle with an eRestyle_SomeDescendants
// restyle hint.
ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR = ELEMENT_FLAG_BIT(4),
// Just the HAS_PENDING bits, for convenience
ELEMENT_PENDING_RESTYLE_FLAGS = ELEMENT_HAS_PENDING_RESTYLE |
ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE,
ELEMENT_PENDING_RESTYLE_FLAGS =
ELEMENT_HAS_PENDING_RESTYLE |
ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE,
// Just the IS_POTENTIAL bits, for convenience
ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS =
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT |
ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT,
// All of the restyle bits together, for convenience.
ELEMENT_ALL_RESTYLE_FLAGS = ELEMENT_PENDING_RESTYLE_FLAGS |
ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS |
ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR,
// Remaining bits are for subclasses
ELEMENT_TYPE_SPECIFIC_BITS_OFFSET = NODE_TYPE_SPECIFIC_BITS_OFFSET + 4
ELEMENT_TYPE_SPECIFIC_BITS_OFFSET = NODE_TYPE_SPECIFIC_BITS_OFFSET + 5
};
#undef ELEMENT_FLAG_BIT

View File

@ -91,7 +91,8 @@ RestyleManager::RestyleManager(nsPresContext* aPresContext)
, mAnimationGeneration(0)
, mReframingStyleContexts(nullptr)
, mPendingRestyles(ELEMENT_HAS_PENDING_RESTYLE |
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT)
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT |
ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR)
#ifdef DEBUG
, mIsProcessingRestyles(false)
#endif

View File

@ -138,7 +138,8 @@ CollectRestyles(nsISupports* aElement,
// Unset the restyle bits now, so if they get readded later as we
// process we won't clobber that adding of the bit.
element->UnsetFlags(collector->tracker->RestyleBit() |
collector->tracker->RootBit());
collector->tracker->RootBit() |
collector->tracker->ConditionalDescendantsBit());
RestyleEnumerateData** restyleArrayPtr = collector->restyleArrayPtr;
RestyleEnumerateData* currentRestyle = *restyleArrayPtr;

View File

@ -240,10 +240,10 @@ public:
NS_PRECONDITION((mRestyleBits & ELEMENT_PENDING_RESTYLE_FLAGS) !=
ELEMENT_PENDING_RESTYLE_FLAGS,
"Shouldn't have both restyle flags set");
NS_PRECONDITION((mRestyleBits & ~ELEMENT_PENDING_RESTYLE_FLAGS) != 0,
NS_PRECONDITION((mRestyleBits & ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS) != 0,
"Must have root flag");
NS_PRECONDITION((mRestyleBits & ~ELEMENT_PENDING_RESTYLE_FLAGS) !=
(ELEMENT_ALL_RESTYLE_FLAGS & ~ELEMENT_PENDING_RESTYLE_FLAGS),
NS_PRECONDITION((mRestyleBits & ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS) !=
ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS,
"Shouldn't have both root flags");
}
@ -284,7 +284,13 @@ public:
// Return our ELEMENT_IS_POTENTIAL_(ANIMATION_)RESTYLE_ROOT bit
Element::FlagsType RootBit() const {
return mRestyleBits & ~ELEMENT_PENDING_RESTYLE_FLAGS;
return mRestyleBits & ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS;
}
// Return our ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR bit if present,
// or 0 if it is not.
Element::FlagsType ConditionalDescendantsBit() const {
return mRestyleBits & ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR;
}
struct Hints {
@ -390,8 +396,9 @@ private:
typedef nsClassHashtable<nsISupportsHashKey, RestyleData> PendingRestyleTable;
typedef nsAutoTArray< nsRefPtr<Element>, 32> RestyleRootArray;
// Our restyle bits. These will be a subset of ELEMENT_ALL_RESTYLE_FLAGS, and
// will include one flag from ELEMENT_PENDING_RESTYLE_FLAGS and one flag
// that's not in ELEMENT_PENDING_RESTYLE_FLAGS.
// will include one flag from ELEMENT_PENDING_RESTYLE_FLAGS, one flag
// from ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS, and might also include
// ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR.
Element::FlagsType mRestyleBits;
RestyleManager* mRestyleManager; // Owns us
// A hashtable that maps elements to pointers to RestyleData structs. The
@ -439,6 +446,13 @@ RestyleTracker::AddPendingRestyleToTable(Element* aElement,
existingData = nullptr;
}
if (aRestyleHint & eRestyle_SomeDescendants) {
NS_ASSERTION(ConditionalDescendantsBit(),
"why are we getting eRestyle_SomeDescendants in an "
"animation-only restyle?");
aElement->SetFlags(ConditionalDescendantsBit());
}
if (!existingData) {
RestyleData* rd =
new RestyleData(aRestyleHint, aMinChangeHint, aRestyleHintData);