Bug 1025308 - Rename the variables associated with skipping style fixups for children element's based on parent display value. r=mats

This commit is contained in:
Susanna Bowen 2014-06-16 09:55:00 -04:00
parent c13f1df2a8
commit 64b0116f8b
7 changed files with 46 additions and 41 deletions

View File

@ -2455,9 +2455,9 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
else {
NS_ASSERTION(aSelf->GetContent(),
"non pseudo-element frame without content node");
// Skip flex-item style fixup for anonymous subtrees:
TreeMatchContext::AutoFlexOrGridItemStyleFixupSkipper
flexOrGridFixupSkipper(mTreeMatchContext,
// Skip parent display based style fixup for anonymous subtrees:
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
parentDisplayBasedFixupSkipper(mTreeMatchContext,
element->IsRootOfNativeAnonymousSubtree());
newContext = styleSet->ResolveStyleFor(element, parentContext,
mTreeMatchContext);

View File

@ -3963,9 +3963,10 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
} else {
FrameConstructionItemList items;
{
// Skip flex item style-fixup during our AddFrameConstructionItems() call:
TreeMatchContext::AutoFlexOrGridItemStyleFixupSkipper
flexOrGridItemStyleFixupSkipper(aState.mTreeMatchContext);
// Skip parent display based style-fixup during our
// AddFrameConstructionItems() call:
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
parentDisplayBasedStyleFixupSkipper(aState.mTreeMatchContext);
AddFrameConstructionItems(aState, content, true, aParentFrame, items);
}
@ -9355,8 +9356,8 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent(
"Why is someone creating garbage anonymous content");
nsRefPtr<nsStyleContext> styleContext;
TreeMatchContext::AutoFlexOrGridItemStyleFixupSkipper
flexOrGridItemStyleFixupSkipper(aState.mTreeMatchContext);
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
parentDisplayBasedStyleFixupSkipper(aState.mTreeMatchContext);
if (aAnonymousItems[i].mStyleContext) {
styleContext = aAnonymousItems[i].mStyleContext.forget();
} else {

View File

@ -289,23 +289,24 @@ struct MOZ_STACK_CLASS TreeMatchContext {
};
/* Helper class for tracking whether we're skipping the ApplyStyleFixups
* code for flex/grid items.
* code for special cases where child element style is modified based on
* parent display value.
*
* The optional second parameter aSkipFlexOrGridItemStyleFixup allows
* The optional second parameter aSkipParentDisplayBasedStyleFixup allows
* this class to be instantiated but only conditionally activated (e.g.
* in cases where we may or may not want to be skipping flex/grid-item
* style fixup for a particular chunk of code).
*/
class MOZ_STACK_CLASS AutoFlexOrGridItemStyleFixupSkipper {
class MOZ_STACK_CLASS AutoParentDisplayBasedStyleFixupSkipper {
public:
AutoFlexOrGridItemStyleFixupSkipper(TreeMatchContext& aTreeMatchContext,
bool aSkipFlexOrGridItemStyleFixup = true
AutoParentDisplayBasedStyleFixupSkipper(TreeMatchContext& aTreeMatchContext,
bool aSkipParentDisplayBasedStyleFixup = true
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mAutoRestorer(aTreeMatchContext.mSkippingFlexOrGridItemStyleFixup)
: mAutoRestorer(aTreeMatchContext.mSkippingParentDisplayBasedStyleFixup)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (aSkipFlexOrGridItemStyleFixup) {
aTreeMatchContext.mSkippingFlexOrGridItemStyleFixup = true;
if (aSkipParentDisplayBasedStyleFixup) {
aTreeMatchContext.mSkippingParentDisplayBasedStyleFixup = true;
}
}
@ -363,10 +364,11 @@ struct MOZ_STACK_CLASS TreeMatchContext {
// Whether this document is using PB mode
bool mUsingPrivateBrowsing;
// Whether we're currently skipping the flex/grid item chunk of
// ApplyStyleFixups when resolving style (e.g. for children of elements that
// have a mandatory frame-type for which we ignore "display:flex/grid").
bool mSkippingFlexOrGridItemStyleFixup;
// Whether we're currently skipping the part of ApplyStyleFixups that changes
// style of child elements based on their parent's display value
// (e.g. for children of elements that have a mandatory frame-type for which
// we ignore "display:flex/grid").
bool mSkippingParentDisplayBasedStyleFixup;
// Whether this TreeMatchContext is being used with an nsCSSRuleProcessor
// for an HTML5 scoped style sheet.
@ -398,7 +400,7 @@ struct MOZ_STACK_CLASS TreeMatchContext {
, mIsHTMLDocument(aDocument->IsHTML())
, mCompatMode(aDocument->GetCompatibilityMode())
, mUsingPrivateBrowsing(false)
, mSkippingFlexOrGridItemStyleFixup(false)
, mSkippingParentDisplayBasedStyleFixup(false)
, mForScopedStyle(false)
, mCurrentStyleScope(nullptr)
{

View File

@ -35,7 +35,7 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexOrGridItemStyleFixup)
bool aSkipParentDisplayBasedStyleFixup)
: mParent(aParent),
mChild(nullptr),
mEmptyChild(nullptr),
@ -71,7 +71,7 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
mRuleNode->AddRef();
mRuleNode->SetUsedDirectly(); // before ApplyStyleFixups()!
ApplyStyleFixups(aSkipFlexOrGridItemStyleFixup);
ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);
#define eStyleStruct_LastItem (nsStyleStructID_Length - 1)
NS_ASSERTION(NS_STYLE_INHERIT_MASK & NS_STYLE_INHERIT_BIT(LastItem),
@ -294,7 +294,7 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
}
void
nsStyleContext::ApplyStyleFixups(bool aSkipFlexOrGridItemStyleFixup)
nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
{
// See if we have any text decorations.
// First see if our parent has text decorations. If our parent does, then we inherit the bit.
@ -359,7 +359,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipFlexOrGridItemStyleFixup)
// # The computed 'display' of a flex item is determined
// # by applying the table in CSS 2.1 Chapter 9.7.
// ...which converts inline-level elements to their block-level equivalents.
if (!aSkipFlexOrGridItemStyleFixup && mParent) {
if (!aSkipParentDisplayBasedStyleFixup && mParent) {
const nsStyleDisplay* parentDisp = mParent->StyleDisplay();
if ((parentDisp->mDisplay == NS_STYLE_DISPLAY_FLEX ||
parentDisp->mDisplay == NS_STYLE_DISPLAY_INLINE_FLEX ||
@ -737,12 +737,12 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexOrGridItemStyleFixup)
bool aSkipParentDisplayBasedStyleFixup)
{
nsRefPtr<nsStyleContext> context =
new (aRuleNode->PresContext())
nsStyleContext(aParentContext, aPseudoTag, aPseudoType, aRuleNode,
aSkipFlexOrGridItemStyleFixup);
aSkipParentDisplayBasedStyleFixup);
return context.forget();
}

View File

@ -56,15 +56,17 @@ public:
* rules that any element, pseudo-element, or
* anonymous box that this style context is for
* matches. See |nsRuleNode| and |nsIStyleRule|.
* @param aSkipFlexOrGridItemStyleFixup
* @param aSkipParentDisplayBasedStyleFixup
* If set, this flag indicates that we should skip
* the chunk of ApplyStyleFixups() that modifies flex
* and grid items' display values.
* the chunk of ApplyStyleFixups() that applies to
* special cases where a child element's style may
* need to be modified based on its parent's display
* value.
*/
nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexOrGridItemStyleFixup);
bool aSkipParentDisplayBasedStyleFixup);
~nsStyleContext();
void* operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW;
@ -348,7 +350,7 @@ protected:
void AddChild(nsStyleContext* aChild);
void RemoveChild(nsStyleContext* aChild);
void ApplyStyleFixups(bool aSkipFlexOrGridItemStyleFixup);
void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
void FreeAllocations(nsPresContext* aPresContext);
@ -442,5 +444,5 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexOrGridItemStyleFixup);
bool aSkipParentDisplayBasedStyleFixup);
#endif

View File

@ -804,12 +804,12 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
if (!result) {
result = NS_NewStyleContext(aParentContext, aPseudoTag, aPseudoType,
aRuleNode,
aFlags & eSkipFlexOrGridItemStyleFixup);
aFlags & eSkipParentDisplayBasedStyleFixup);
if (aVisitedRuleNode) {
nsRefPtr<nsStyleContext> resultIfVisited =
NS_NewStyleContext(parentIfVisited, aPseudoTag, aPseudoType,
aVisitedRuleNode,
aFlags & eSkipFlexOrGridItemStyleFixup);
aFlags & eSkipParentDisplayBasedStyleFixup);
if (!parentIfVisited) {
mRoots.AppendElement(resultIfVisited);
}
@ -1225,8 +1225,8 @@ nsStyleSet::ResolveStyleFor(Element* aElement,
HasState(NS_EVENT_STATE_VISITED)) {
flags |= eIsVisitedLink;
}
if (aTreeMatchContext.mSkippingFlexOrGridItemStyleFixup) {
flags |= eSkipFlexOrGridItemStyleFixup;
if (aTreeMatchContext.mSkippingParentDisplayBasedStyleFixup) {
flags |= eSkipParentDisplayBasedStyleFixup;
}
return GetContext(aParentContext, ruleNode, visitedRuleNode,
@ -1393,7 +1393,7 @@ nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
// aside from ::before and ::after. So if we have such a child, we're not
// actually in a flex/grid container, and we should skip flex/grid item
// style fixup.
flags |= eSkipFlexOrGridItemStyleFixup;
flags |= eSkipParentDisplayBasedStyleFixup;
}
return GetContext(aParentContext, ruleNode, visitedRuleNode,
@ -1465,7 +1465,7 @@ nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
// aside from ::before and ::after. So if we have such a child, we're not
// actually in a flex/grid container, and we should skip flex/grid item
// style fixup.
flags |= eSkipFlexOrGridItemStyleFixup;
flags |= eSkipParentDisplayBasedStyleFixup;
}
nsRefPtr<nsStyleContext> result =
@ -1893,7 +1893,7 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
// or not the parent is styled as a flex/grid container. (If the parent
// has anonymous-subtree kids, then we know it's not actually going to get
// a flex/grid container frame, anyway.)
flags |= eSkipFlexOrGridItemStyleFixup;
flags |= eSkipParentDisplayBasedStyleFixup;
}
return GetContext(aNewParentContext, ruleNode, visitedRuleNode,

View File

@ -407,7 +407,7 @@ class nsStyleSet
// or "display: grid" but we can tell we're not going to honor that (e.g. if
// it's the outer frame of a button widget, and we're the inline frame for
// the button's label).
eSkipFlexOrGridItemStyleFixup = 1 << 3
eSkipParentDisplayBasedStyleFixup = 1 << 3
};
already_AddRefed<nsStyleContext>