Bug 1000376 - part 3, s/FlexItemStyleFixup/FlexOrGridItemStyleFixup/ and corresponding comment changes. r=dholbert

This commit is contained in:
Mats Palmgren 2014-05-03 13:42:33 +00:00
parent 6b4f00d46c
commit cdd8fec4ec
7 changed files with 61 additions and 57 deletions

View File

@ -2448,9 +2448,9 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
NS_ASSERTION(aSelf->GetContent(),
"non pseudo-element frame without content node");
// Skip flex-item style fixup for anonymous subtrees:
TreeMatchContext::AutoFlexItemStyleFixupSkipper
flexFixupSkipper(mTreeMatchContext,
element->IsRootOfNativeAnonymousSubtree());
TreeMatchContext::AutoFlexOrGridItemStyleFixupSkipper
flexOrGridFixupSkipper(mTreeMatchContext,
element->IsRootOfNativeAnonymousSubtree());
newContext = styleSet->ResolveStyleFor(element, parentContext,
mTreeMatchContext);
}

View File

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

View File

@ -299,23 +299,23 @@ struct MOZ_STACK_CLASS TreeMatchContext {
};
/* Helper class for tracking whether we're skipping the ApplyStyleFixups
* code for flex items.
* code for flex/grid items.
*
* The optional second parameter aSkipFlexItemStyleFixup 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-item
* The optional second parameter aSkipFlexOrGridItemStyleFixup 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 AutoFlexItemStyleFixupSkipper {
class MOZ_STACK_CLASS AutoFlexOrGridItemStyleFixupSkipper {
public:
AutoFlexItemStyleFixupSkipper(TreeMatchContext& aTreeMatchContext,
bool aSkipFlexItemStyleFixup = true
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mAutoRestorer(aTreeMatchContext.mSkippingFlexItemStyleFixup)
AutoFlexOrGridItemStyleFixupSkipper(TreeMatchContext& aTreeMatchContext,
bool aSkipFlexOrGridItemStyleFixup = true
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mAutoRestorer(aTreeMatchContext.mSkippingFlexOrGridItemStyleFixup)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (aSkipFlexItemStyleFixup) {
aTreeMatchContext.mSkippingFlexItemStyleFixup = true;
if (aSkipFlexOrGridItemStyleFixup) {
aTreeMatchContext.mSkippingFlexOrGridItemStyleFixup = true;
}
}
@ -373,10 +373,10 @@ struct MOZ_STACK_CLASS TreeMatchContext {
// Whether this document is using PB mode
bool mUsingPrivateBrowsing;
// Whether we're currently skipping the flex item chunk of ApplyStyleFixups
// when resolving style (e.g. for children of elements that have a mandatory
// frame-type and can't be flex containers despite having "display:flex").
bool mSkippingFlexItemStyleFixup;
// 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 this TreeMatchContext is being used with an nsCSSRuleProcessor
// for an HTML5 scoped style sheet.
@ -408,7 +408,7 @@ struct MOZ_STACK_CLASS TreeMatchContext {
, mIsHTMLDocument(aDocument->IsHTML())
, mCompatMode(aDocument->GetCompatibilityMode())
, mUsingPrivateBrowsing(false)
, mSkippingFlexItemStyleFixup(false)
, mSkippingFlexOrGridItemStyleFixup(false)
, mForScopedStyle(false)
, mCurrentStyleScope(nullptr)
{

View File

@ -35,7 +35,7 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexItemStyleFixup)
bool aSkipFlexOrGridItemStyleFixup)
: mParent(aParent),
mChild(nullptr),
mEmptyChild(nullptr),
@ -71,7 +71,7 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
mRuleNode->AddRef();
mRuleNode->SetUsedDirectly(); // before ApplyStyleFixups()!
ApplyStyleFixups(aSkipFlexItemStyleFixup);
ApplyStyleFixups(aSkipFlexOrGridItemStyleFixup);
#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 aSkipFlexItemStyleFixup)
nsStyleContext::ApplyStyleFixups(bool aSkipFlexOrGridItemStyleFixup)
{
// 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 aSkipFlexItemStyleFixup)
// # 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 (!aSkipFlexItemStyleFixup && mParent) {
if (!aSkipFlexOrGridItemStyleFixup && mParent) {
const nsStyleDisplay* parentDisp = mParent->StyleDisplay();
if ((parentDisp->mDisplay == NS_STYLE_DISPLAY_FLEX ||
parentDisp->mDisplay == NS_STYLE_DISPLAY_INLINE_FLEX ||
@ -382,10 +382,11 @@ nsStyleContext::ApplyStyleFixups(bool aSkipFlexItemStyleFixup)
NS_STYLE_DISPLAY_TABLE_CELL != displayVal) {
// NOTE: Technically, we shouldn't modify the 'display' value of
// positioned elements, since they aren't flex items. However, we don't
// need to worry about checking for that, because if we're positioned,
// we'll have already been through a call to EnsureBlockDisplay() in
// nsRuleNode, so this call here won't change anything. So we're OK.
// positioned elements, since they aren't flex/grid items. However,
// we don't need to worry about checking for that, because if we're
// positioned, we'll have already been through a call to
// EnsureBlockDisplay() in nsRuleNode, so this call here won't change
// anything. So we're OK.
nsRuleNode::EnsureBlockDisplay(displayVal);
if (displayVal != disp->mDisplay) {
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle(),
@ -735,12 +736,12 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexItemStyleFixup)
bool aSkipFlexOrGridItemStyleFixup)
{
nsRefPtr<nsStyleContext> context =
new (aRuleNode->PresContext())
nsStyleContext(aParentContext, aPseudoTag, aPseudoType, aRuleNode,
aSkipFlexItemStyleFixup);
aSkipFlexOrGridItemStyleFixup);
return context.forget();
}

View File

@ -56,15 +56,15 @@ public:
* rules that any element, pseudo-element, or
* anonymous box that this style context is for
* matches. See |nsRuleNode| and |nsIStyleRule|.
* @param aSkipFlexItemStyleFixup
* @param aSkipFlexOrGridItemStyleFixup
* If set, this flag indicates that we should skip
* the chunk of ApplyStyleFixups() that modifies flex
* items' display values.
* and grid items' display values.
*/
nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexItemStyleFixup);
bool aSkipFlexOrGridItemStyleFixup);
~nsStyleContext();
void* operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW;
@ -348,7 +348,7 @@ protected:
void AddChild(nsStyleContext* aChild);
void RemoveChild(nsStyleContext* aChild);
void ApplyStyleFixups(bool aSkipFlexItemStyleFixup);
void ApplyStyleFixups(bool aSkipFlexOrGridItemStyleFixup);
void FreeAllocations(nsPresContext* aPresContext);
@ -442,5 +442,5 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
nsIAtom* aPseudoTag,
nsCSSPseudoElements::Type aPseudoType,
nsRuleNode* aRuleNode,
bool aSkipFlexItemStyleFixup);
bool aSkipFlexOrGridItemStyleFixup);
#endif

View File

@ -794,12 +794,13 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
if (!result) {
result = NS_NewStyleContext(aParentContext, aPseudoTag, aPseudoType,
aRuleNode, aFlags & eSkipFlexItemStyleFixup);
aRuleNode,
aFlags & eSkipFlexOrGridItemStyleFixup);
if (aVisitedRuleNode) {
nsRefPtr<nsStyleContext> resultIfVisited =
NS_NewStyleContext(parentIfVisited, aPseudoTag, aPseudoType,
aVisitedRuleNode,
aFlags & eSkipFlexItemStyleFixup);
aFlags & eSkipFlexOrGridItemStyleFixup);
if (!parentIfVisited) {
mRoots.AppendElement(resultIfVisited);
}
@ -1214,8 +1215,8 @@ nsStyleSet::ResolveStyleFor(Element* aElement,
HasState(NS_EVENT_STATE_VISITED)) {
flags |= eIsVisitedLink;
}
if (aTreeMatchContext.mSkippingFlexItemStyleFixup) {
flags |= eSkipFlexItemStyleFixup;
if (aTreeMatchContext.mSkippingFlexOrGridItemStyleFixup) {
flags |= eSkipFlexOrGridItemStyleFixup;
}
return GetContext(aParentContext, ruleNode, visitedRuleNode,
@ -1378,10 +1379,11 @@ nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
aType == nsCSSPseudoElements::ePseudo_after) {
flags |= eDoAnimation;
} else {
// Flex containers don't expect to have any pseudo-element children aside
// from ::before and ::after. So if we have such a child, we're not
// actually in a flex container, and we should skip flex-item style fixup.
flags |= eSkipFlexItemStyleFixup;
// Flex and grid containers don't expect to have any pseudo-element children
// 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;
}
return GetContext(aParentContext, ruleNode, visitedRuleNode,
@ -1449,10 +1451,11 @@ nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
aType == nsCSSPseudoElements::ePseudo_after) {
flags |= eDoAnimation;
} else {
// Flex containers don't expect to have any pseudo-element children aside
// from ::before and ::after. So if we have such a child, we're not
// actually in a flex container, and we should skip flex-item style fixup.
flags |= eSkipFlexItemStyleFixup;
// Flex and grid containers don't expect to have any pseudo-element children
// 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;
}
nsRefPtr<nsStyleContext> result =
@ -1856,11 +1859,11 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
}
if (aElement && aElement->IsRootOfAnonymousSubtree()) {
// For anonymous subtree roots, don't tweak "display" value based on
// whether or not the parent is styled as a flex container. (If the parent
// For anonymous subtree roots, don't tweak "display" value based on whether
// 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 container frame, anyway.)
flags |= eSkipFlexItemStyleFixup;
// a flex/grid container frame, anyway.)
flags |= eSkipFlexOrGridItemStyleFixup;
}
return GetContext(aNewParentContext, ruleNode, visitedRuleNode,

View File

@ -397,12 +397,12 @@ class nsStyleSet
eIsVisitedLink = 1 << 1,
eDoAnimation = 1 << 2,
// Indicates that we should skip the flex-item-specific chunk of
// Indicates that we should skip the flex/grid item specific chunk of
// ApplyStyleFixups(). This is useful if our parent has "display: flex"
// but we can tell it's not going to actually be a flex container (e.g. if
// 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).
eSkipFlexItemStyleFixup = 1 << 3
eSkipFlexOrGridItemStyleFixup = 1 << 3
};
already_AddRefed<nsStyleContext>