Bug 1506687 Part 2: Make FlexItemValues also provide the item's position and size. r=dholbert

Depends on D11782

Differential Revision: https://phabricator.services.mozilla.com/D11783

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2018-11-15 16:20:40 +00:00
Родитель ff2db4f169
Коммит 5e72dc5a5b
5 изменённых файлов: 67 добавлений и 10 удалений

Просмотреть файл

@ -83,10 +83,14 @@ enum FlexItemClampState {
interface FlexItemValues
{
readonly attribute Node? node;
readonly attribute double mainPosition;
readonly attribute double mainSize;
readonly attribute double mainBaseSize;
readonly attribute double mainDeltaSize;
readonly attribute double mainMinSize;
readonly attribute double mainMaxSize;
readonly attribute double crossPosition;
readonly attribute double crossSize;
readonly attribute double crossMinSize;
readonly attribute double crossMaxSize;
readonly attribute FlexItemClampState clampState;

Просмотреть файл

@ -50,6 +50,10 @@ FlexItemValues::FlexItemValues(FlexLineValues* aParent,
mNode = aItem->mNode;
// Convert app unit sizes to css pixel sizes.
mMainPosition = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainPosition);
mMainSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainSize);
mMainBaseSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainBaseSize);
mMainDeltaSize = nsPresContext::AppUnitsToDoubleCSSPixels(
@ -57,6 +61,10 @@ FlexItemValues::FlexItemValues(FlexLineValues* aParent,
mMainMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainMinSize);
mMainMaxSize = ToPossiblyUnconstrainedPixels(aItem->mMainMaxSize);
mCrossPosition = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossPosition);
mCrossSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossSize);
mCrossMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossMinSize);
mCrossMaxSize = ToPossiblyUnconstrainedPixels(aItem->mCrossMaxSize);
@ -76,6 +84,18 @@ FlexItemValues::GetNode() const
return mNode;
}
double
FlexItemValues::MainPosition() const
{
return mMainPosition;
}
double
FlexItemValues::MainSize() const
{
return mMainSize;
}
double
FlexItemValues::MainBaseSize() const
{
@ -100,6 +120,18 @@ FlexItemValues::MainMaxSize() const
return mMainMaxSize;
}
double
FlexItemValues::CrossPosition() const
{
return mCrossPosition;
}
double
FlexItemValues::CrossSize() const
{
return mCrossSize;
}
double
FlexItemValues::CrossMinSize() const
{

Просмотреть файл

@ -39,10 +39,14 @@ public:
}
nsINode* GetNode() const;
double MainPosition() const;
double MainSize() const;
double MainBaseSize() const;
double MainDeltaSize() const;
double MainMinSize() const;
double MainMaxSize() const;
double CrossPosition() const;
double CrossSize() const;
double CrossMinSize() const;
double CrossMaxSize() const;
FlexItemClampState ClampState() const;
@ -51,11 +55,15 @@ protected:
RefPtr<FlexLineValues> mParent;
RefPtr<nsINode> mNode;
// These sizes are all CSS pixel units.
// These measurements are all CSS pixel units.
double mMainPosition;
double mMainSize;
double mMainBaseSize;
double mMainDeltaSize;
double mMainMinSize;
double mMainMaxSize;
double mCrossPosition;
double mCrossSize;
double mCrossMinSize;
double mCrossMaxSize;
FlexItemClampState mClampState;

Просмотреть файл

@ -4798,14 +4798,9 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
ComputedFlexItemInfo* itemInfo = lineInfo->mItems.AppendElement();
itemInfo->mNode = node;
// mMainBaseSize and itemInfo->mMainDeltaSize will
// be filled out in ResolveFlexibleLengths().
// Other FlexItem properties can be captured now.
itemInfo->mMainMinSize = item->GetMainMinSize();
itemInfo->mMainMaxSize = item->GetMainMaxSize();
itemInfo->mCrossMinSize = item->GetCrossMinSize();
itemInfo->mCrossMaxSize = item->GetCrossMaxSize();
// itemInfo->mMainBaseSize and mMainDeltaSize will be filled out
// in ResolveFlexibleLengths(). Other measurements will be captured
// at the end of this function.
}
}
}
@ -5210,7 +5205,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize)
// Finally update our line sizing values in our containerInfo.
// Finally update our line and item measurements in our containerInfo.
if (MOZ_UNLIKELY(containerInfo)) {
lineIndex = 0;
for (const FlexLine* line = lines.getFirst(); line;
@ -5220,6 +5215,20 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
lineInfo.mCrossSize = line->GetLineCrossSize();
lineInfo.mFirstBaselineOffset = line->GetFirstBaselineOffset();
lineInfo.mLastBaselineOffset = line->GetLastBaselineOffset();
uint32_t itemIndex = 0;
for (const FlexItem* item = line->GetFirstItem(); item;
item = item->getNext(), ++itemIndex) {
ComputedFlexItemInfo& itemInfo = lineInfo.mItems[itemIndex];
itemInfo.mMainPosition = item->GetMainPosition();
itemInfo.mMainSize = item->GetMainSize();
itemInfo.mMainMinSize = item->GetMainMinSize();
itemInfo.mMainMaxSize = item->GetMainMaxSize();
itemInfo.mCrossPosition = item->GetCrossPosition();
itemInfo.mCrossSize = item->GetCrossSize();
itemInfo.mCrossMinSize = item->GetCrossMinSize();
itemInfo.mCrossMaxSize = item->GetCrossMaxSize();
}
}
}
}

Просмотреть файл

@ -33,6 +33,8 @@ nsContainerFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
struct ComputedFlexItemInfo
{
nsCOMPtr<nsINode> mNode;
nscoord mMainPosition;
nscoord mMainSize;
/**
* mMainBaseSize is a measure of the size of the item in the main
* axis before the flex sizing algorithm is applied. In the spec,
@ -52,6 +54,8 @@ struct ComputedFlexItemInfo
nscoord mMainDeltaSize;
nscoord mMainMinSize;
nscoord mMainMaxSize;
nscoord mCrossPosition;
nscoord mCrossSize;
nscoord mCrossMinSize;
nscoord mCrossMaxSize;
mozilla::dom::FlexItemClampState mClampState;