Bug 1398963 part 3: Generalize "webkit-box" variable names and code-comments in nsCSSFrameConstructor.cpp (idempotent patch). r=mats

Now that (per previous patch) NS_STATE_FLEX_IS_EMULATING_LEGACY_BOX isn't just
a webkit-box-specific tag: this patch here generalizes the variable-names and
comments associated with that flag in nsCSSFrameConstructor.cpp.

This patch does not make any changes to behavior; it's simply renaming &
comment tweaks.

MozReview-Commit-ID: DcF5GirAQwD

--HG--
extra : rebase_source : d847c5579399a4cc31dc14a52a93b03ed917034e
This commit is contained in:
Daniel Holbert 2017-12-18 12:17:10 -06:00
parent 0d839c700e
commit 91270c255f

View File

@ -380,7 +380,7 @@ IsFlexOrGridContainer(const nsIFrame* aFrame)
} }
// Returns true IFF the given nsIFrame is a nsFlexContainerFrame and // Returns true IFF the given nsIFrame is a nsFlexContainerFrame and
// represents a -webkit-{inline-}box container. // represents a -webkit-{inline-}box or -moz-{inline-}box container.
static inline bool static inline bool
IsFlexContainerForLegacyBox(const nsIFrame* aFrame) IsFlexContainerForLegacyBox(const nsIFrame* aFrame)
{ {
@ -10032,11 +10032,11 @@ nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems(
return; return;
} }
const bool isWebkitBox = IsFlexContainerForLegacyBox(aParentFrame); const bool isLegacyBox = IsFlexContainerForLegacyBox(aParentFrame);
FCItemIterator iter(aItems); FCItemIterator iter(aItems);
do { do {
// Advance iter past children that don't want to be wrapped // Advance iter past children that don't want to be wrapped
if (iter.SkipItemsThatDontNeedAnonFlexOrGridItem(aState, isWebkitBox)) { if (iter.SkipItemsThatDontNeedAnonFlexOrGridItem(aState, isLegacyBox)) {
// Hit the end of the items without finding any remaining children that // Hit the end of the items without finding any remaining children that
// need to be wrapped. We're finished! // need to be wrapped. We're finished!
return; return;
@ -10059,7 +10059,7 @@ nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems(
bool hitEnd = afterWhitespaceIter.SkipWhitespace(aState); bool hitEnd = afterWhitespaceIter.SkipWhitespace(aState);
bool nextChildNeedsAnonItem = bool nextChildNeedsAnonItem =
!hitEnd && !hitEnd &&
afterWhitespaceIter.item().NeedsAnonFlexOrGridItem(aState, isWebkitBox); afterWhitespaceIter.item().NeedsAnonFlexOrGridItem(aState, isLegacyBox);
if (!nextChildNeedsAnonItem) { if (!nextChildNeedsAnonItem) {
// There's nothing after the whitespace that we need to wrap, so we // There's nothing after the whitespace that we need to wrap, so we
@ -10073,7 +10073,7 @@ nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems(
// we jump back to the beginning of the loop to skip over that child // we jump back to the beginning of the loop to skip over that child
// (and anything else non-wrappable after it) // (and anything else non-wrappable after it)
MOZ_ASSERT(!iter.IsDone() && MOZ_ASSERT(!iter.IsDone() &&
!iter.item().NeedsAnonFlexOrGridItem(aState, isWebkitBox), !iter.item().NeedsAnonFlexOrGridItem(aState, isLegacyBox),
"hitEnd and/or nextChildNeedsAnonItem lied"); "hitEnd and/or nextChildNeedsAnonItem lied");
continue; continue;
} }
@ -10083,7 +10083,7 @@ nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems(
// anonymous flex/grid item. Now we see how many children after it also want // anonymous flex/grid item. Now we see how many children after it also want
// to be wrapped in an anonymous flex/grid item. // to be wrapped in an anonymous flex/grid item.
FCItemIterator endIter(iter); // iterator to find the end of the group FCItemIterator endIter(iter); // iterator to find the end of the group
endIter.SkipItemsThatNeedAnonFlexOrGridItem(aState, isWebkitBox); endIter.SkipItemsThatNeedAnonFlexOrGridItem(aState, isLegacyBox);
NS_ASSERTION(iter != endIter, NS_ASSERTION(iter != endIter,
"Should've had at least one wrappable child to seek past"); "Should've had at least one wrappable child to seek past");
@ -10720,8 +10720,8 @@ FrameWantsToBeInAnonymousItem(const nsIFrame* aContainerFrame,
return true; return true;
} }
// If the container is a -webkit-box/-webkit-inline-box, then placeholders // If the container is a -webkit-{inline-}box or -moz-{inline-}box container,
// also need to be wrapped, for compatibility. // then placeholders also need to be wrapped, for compatibility.
if (IsFlexContainerForLegacyBox(aContainerFrame) && if (IsFlexContainerForLegacyBox(aContainerFrame) &&
aFrame->IsPlaceholderFrame()) { aFrame->IsPlaceholderFrame()) {
return true; return true;
@ -12402,9 +12402,9 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState,
// Check if we're adding to-be-wrapped content right *after* an existing // Check if we're adding to-be-wrapped content right *after* an existing
// anonymous flex or grid item (which would need to absorb this content). // anonymous flex or grid item (which would need to absorb this content).
const bool isWebkitBox = IsFlexContainerForLegacyBox(aFrame); const bool isLegacyBox = IsFlexContainerForLegacyBox(aFrame);
if (aPrevSibling && IsAnonymousFlexOrGridItem(aPrevSibling) && if (aPrevSibling && IsAnonymousFlexOrGridItem(aPrevSibling) &&
iter.item().NeedsAnonFlexOrGridItem(aState, isWebkitBox)) { iter.item().NeedsAnonFlexOrGridItem(aState, isLegacyBox)) {
RecreateFramesForContent(aFrame->GetContent(), InsertionKind::Async); RecreateFramesForContent(aFrame->GetContent(), InsertionKind::Async);
return true; return true;
} }
@ -12415,7 +12415,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState,
// Jump to the last entry in the list // Jump to the last entry in the list
iter.SetToEnd(); iter.SetToEnd();
iter.Prev(); iter.Prev();
if (iter.item().NeedsAnonFlexOrGridItem(aState, isWebkitBox)) { if (iter.item().NeedsAnonFlexOrGridItem(aState, isLegacyBox)) {
RecreateFramesForContent(aFrame->GetContent(), InsertionKind::Async); RecreateFramesForContent(aFrame->GetContent(), InsertionKind::Async);
return true; return true;
} }
@ -12440,8 +12440,8 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState,
// Skip over things that _do_ need an anonymous flex item, because // Skip over things that _do_ need an anonymous flex item, because
// they're perfectly happy to go here -- they won't cause a reframe. // they're perfectly happy to go here -- they won't cause a reframe.
nsIFrame* containerFrame = aFrame->GetParent(); nsIFrame* containerFrame = aFrame->GetParent();
const bool isWebkitBox = IsFlexContainerForLegacyBox(containerFrame); const bool isLegacyBox = IsFlexContainerForLegacyBox(containerFrame);
if (!iter.SkipItemsThatNeedAnonFlexOrGridItem(aState, isWebkitBox)) { if (!iter.SkipItemsThatNeedAnonFlexOrGridItem(aState, isLegacyBox)) {
// We hit something that _doesn't_ need an anonymous flex item! // We hit something that _doesn't_ need an anonymous flex item!
// Rebuild the flex container to bust it out. // Rebuild the flex container to bust it out.
RecreateFramesForContent(containerFrame->GetContent(), InsertionKind::Async); RecreateFramesForContent(containerFrame->GetContent(), InsertionKind::Async);
@ -12884,31 +12884,32 @@ Iterator::SkipItemsNotWantingParentType(ParentType aParentType)
return false; return false;
} }
// Note: we implement -webkit-box & -webkit-inline-box using // Note: we implement -webkit-{inline-}box (and optionally -moz-{inline-}box)
// nsFlexContainerFrame, but we use different rules for what gets wrapped in an // using nsFlexContainerFrame, but we use different rules for what gets wrapped
// anonymous flex item. // in an anonymous flex item.
bool bool
nsCSSFrameConstructor::FrameConstructionItem:: nsCSSFrameConstructor::FrameConstructionItem::
NeedsAnonFlexOrGridItem(const nsFrameConstructorState& aState, NeedsAnonFlexOrGridItem(const nsFrameConstructorState& aState,
bool aIsWebkitBox) bool aIsLegacyBox)
{ {
if (mFCData->mBits & FCDATA_IS_LINE_PARTICIPANT) { if (mFCData->mBits & FCDATA_IS_LINE_PARTICIPANT) {
// This will be an inline non-replaced box. // This will be an inline non-replaced box.
return true; return true;
} }
if (aIsWebkitBox) { if (aIsLegacyBox) {
if (mStyleContext->StyleDisplay()->IsInlineOutsideStyle()) { if (mStyleContext->StyleDisplay()->IsInlineOutsideStyle()) {
// In a -webkit-box, all inline-level content gets wrapped in anon item. // In an emulated legacy box, all inline-level content gets wrapped in an
// anonymous flex item.
return true; return true;
} }
if (!(mFCData->mBits & FCDATA_DISALLOW_OUT_OF_FLOW) && if (!(mFCData->mBits & FCDATA_DISALLOW_OUT_OF_FLOW) &&
aState.GetGeometricParent(mStyleContext->StyleDisplay(), nullptr)) { aState.GetGeometricParent(mStyleContext->StyleDisplay(), nullptr)) {
// We're abspos or fixedpos, which means we'll spawn a placeholder which // We're abspos or fixedpos, which means we'll spawn a placeholder which
// (because our container is a -webkit-box) we'll need to wrap in an // (because our container is an emulated legacy box) we'll need to wrap
// anonymous flex item. So, we just treat _this_ frame as if _it_ needs // in an anonymous flex item. So, we just treat _this_ frame as if _it_
// to be wrapped in an anonymous flex item, and then when we spawn the // needs to be wrapped in an anonymous flex item, and then when we spawn
// placeholder, it'll end up in the right spot. // the placeholder, it'll end up in the right spot.
return true; return true;
} }
} }
@ -12920,10 +12921,10 @@ inline bool
nsCSSFrameConstructor::FrameConstructionItemList:: nsCSSFrameConstructor::FrameConstructionItemList::
Iterator::SkipItemsThatNeedAnonFlexOrGridItem( Iterator::SkipItemsThatNeedAnonFlexOrGridItem(
const nsFrameConstructorState& aState, const nsFrameConstructorState& aState,
bool aIsWebkitBox) bool aIsLegacyBox)
{ {
NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
while (item().NeedsAnonFlexOrGridItem(aState, aIsWebkitBox)) { while (item().NeedsAnonFlexOrGridItem(aState, aIsLegacyBox)) {
Next(); Next();
if (IsDone()) { if (IsDone()) {
return true; return true;
@ -12936,10 +12937,10 @@ inline bool
nsCSSFrameConstructor::FrameConstructionItemList:: nsCSSFrameConstructor::FrameConstructionItemList::
Iterator::SkipItemsThatDontNeedAnonFlexOrGridItem( Iterator::SkipItemsThatDontNeedAnonFlexOrGridItem(
const nsFrameConstructorState& aState, const nsFrameConstructorState& aState,
bool aIsWebkitBox) bool aIsLegacyBox)
{ {
NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); NS_PRECONDITION(!IsDone(), "Shouldn't be done yet");
while (!(item().NeedsAnonFlexOrGridItem(aState, aIsWebkitBox))) { while (!(item().NeedsAnonFlexOrGridItem(aState, aIsLegacyBox))) {
Next(); Next();
if (IsDone()) { if (IsDone()) {
return true; return true;