зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1501109 Part 1: Change Flex API growth state to match layout algorithm, and use enums from webidl. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D9454 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
564994962f
Коммит
29992e3858
|
@ -39,10 +39,17 @@ interface Flex
|
|||
};
|
||||
|
||||
/**
|
||||
* Lines with items that have been shrunk are shrinking; with items
|
||||
* that have grown are growing, and all others are unchanged.
|
||||
* This indicates which flex factor (flex-grow vs. flex-shrink) the
|
||||
* flex layout algorithm uses internally when resolving flexible sizes
|
||||
* in a given flex line, per flexbox spec section 9.7 step 1. Note that
|
||||
* this value doesn't necessarily mean that any items on this line
|
||||
* are *actually* growing (or shrinking). This simply indicates what
|
||||
* the layout algorithm "wants" to do, based on the free space --
|
||||
* and items will stretch from their flex base size in the corresponding
|
||||
* direction, if permitted by their min/max constraints and their
|
||||
* corresponding flex factor.
|
||||
*/
|
||||
enum FlexLineGrowthState { "unchanged", "shrinking", "growing" };
|
||||
enum FlexLineGrowthState { "shrinking", "growing" };
|
||||
|
||||
[ChromeOnly]
|
||||
interface FlexLineValues
|
||||
|
|
|
@ -30,18 +30,7 @@ FlexLineValues::FlexLineValues(Flex* aParent,
|
|||
|
||||
// Eagerly copy values from aLine, because we're not
|
||||
// going to keep it around.
|
||||
switch (aLine->mGrowthState) {
|
||||
case ComputedFlexLineInfo::GrowthState::SHRINKING:
|
||||
mGrowthState = FlexLineGrowthState::Shrinking;
|
||||
break;
|
||||
|
||||
case ComputedFlexLineInfo::GrowthState::GROWING:
|
||||
mGrowthState = FlexLineGrowthState::Growing;
|
||||
break;
|
||||
|
||||
default:
|
||||
mGrowthState = FlexLineGrowthState::Unchanged;
|
||||
};
|
||||
mGrowthState = aLine->mGrowthState;
|
||||
|
||||
// Convert all the app unit values into css pixels.
|
||||
mCrossStart = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
|
|
|
@ -2643,6 +2643,12 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
|
|||
const bool isUsingFlexGrow =
|
||||
(mTotalOuterHypotheticalMainSize < aFlexContainerMainSize);
|
||||
|
||||
if (aLineInfo) {
|
||||
aLineInfo->mGrowthState = isUsingFlexGrow ?
|
||||
mozilla::dom::FlexLineGrowthState::Growing :
|
||||
mozilla::dom::FlexLineGrowthState::Shrinking;
|
||||
}
|
||||
|
||||
// Do an "early freeze" for flex items that obviously can't flex in the
|
||||
// direction we've chosen:
|
||||
FreezeItemsEarly(isUsingFlexGrow, aLineInfo);
|
||||
|
@ -2872,30 +2878,6 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
|
|||
aLineInfo->mItems[itemIndex].mMainBaseSize;
|
||||
|
||||
aLineInfo->mItems[itemIndex].mMainDeltaSize = deltaSize;
|
||||
// If any (unfrozen) item on the line is growing, we mark the
|
||||
// aLineInfo structure; likewise if any item is shrinking.
|
||||
// (Note: a line can't contain a mix of items that are growing
|
||||
// and shrinking. Also, the sign of any delta should match the
|
||||
// type of flex factor we're using [grow vs shrink].)
|
||||
if (deltaSize > 0) {
|
||||
MOZ_ASSERT(isUsingFlexGrow,
|
||||
"Unfrozen items can only grow if we're "
|
||||
"distributing (positive) space with flex-grow");
|
||||
MOZ_ASSERT(aLineInfo->mGrowthState !=
|
||||
ComputedFlexLineInfo::GrowthState::SHRINKING,
|
||||
"shouldn't flip flop from shrinking to growing");
|
||||
aLineInfo->mGrowthState =
|
||||
ComputedFlexLineInfo::GrowthState::GROWING;
|
||||
} else if (deltaSize < 0) {
|
||||
MOZ_ASSERT(!isUsingFlexGrow,
|
||||
"Unfrozen items can only shrink if we're "
|
||||
"distributing (negative) space with flex-shrink");
|
||||
MOZ_ASSERT(aLineInfo->mGrowthState !=
|
||||
ComputedFlexLineInfo::GrowthState::GROWING,
|
||||
"shouldn't flip flop from growing to shrinking");
|
||||
aLineInfo->mGrowthState =
|
||||
ComputedFlexLineInfo::GrowthState::SHRINKING;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4770,16 +4752,10 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
|
|||
line = line->getNext()) {
|
||||
ComputedFlexLineInfo* lineInfo =
|
||||
containerInfo->mLines.AppendElement();
|
||||
// Most lineInfo properties will be set later, but we set
|
||||
// mGrowthState to UNCHANGED here because it may be later
|
||||
// modified by ResolveFlexibleLengths().
|
||||
lineInfo->mGrowthState =
|
||||
ComputedFlexLineInfo::GrowthState::UNCHANGED;
|
||||
|
||||
// The remaining lineInfo properties will be filled out at the
|
||||
// end of this function, when we have real values. But we still
|
||||
// add all the items here, so we can capture computed data for
|
||||
// each item.
|
||||
// Most of the remaining lineInfo properties will be filled out at the
|
||||
// end of this function (some will be provided by other functions),
|
||||
// when we have real values. But we still add all the items here, so
|
||||
// we can capture computed data for each item as we proceed.
|
||||
for (const FlexItem* item = line->GetFirstItem(); item;
|
||||
item = item->getNext()) {
|
||||
nsIFrame* frame = item->Frame();
|
||||
|
|
|
@ -63,11 +63,7 @@ struct ComputedFlexLineInfo
|
|||
nscoord mCrossSize;
|
||||
nscoord mFirstBaselineOffset;
|
||||
nscoord mLastBaselineOffset;
|
||||
enum GrowthState {
|
||||
UNCHANGED,
|
||||
SHRINKING,
|
||||
GROWING,
|
||||
} mGrowthState;
|
||||
mozilla::dom::FlexLineGrowthState mGrowthState;
|
||||
};
|
||||
|
||||
struct ComputedFlexContainerInfo
|
||||
|
|
Загрузка…
Ссылка в новой задаче