зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1506687 Part 1: Make FlexItemValues also provide the item's frame rect. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D12182 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d1b2c17c02
Коммит
cae2b12074
|
@ -83,6 +83,7 @@ enum FlexItemClampState {
|
|||
interface FlexItemValues
|
||||
{
|
||||
readonly attribute Node? node;
|
||||
readonly attribute DOMRectReadOnly frameRect;
|
||||
readonly attribute double mainBaseSize;
|
||||
readonly attribute double mainDeltaSize;
|
||||
readonly attribute double mainMinSize;
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FlexItemValues, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FlexItemValues, mParent, mNode,
|
||||
mFrameRect)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(FlexItemValues)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(FlexItemValues)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexItemValues)
|
||||
|
@ -49,6 +50,14 @@ FlexItemValues::FlexItemValues(FlexLineValues* aParent,
|
|||
// going to keep it around.
|
||||
mNode = aItem->mNode;
|
||||
|
||||
// Since mNode might be null, we associate the mFrameRect with
|
||||
// our parent.
|
||||
mFrameRect = new DOMRectReadOnly(mParent,
|
||||
nsPresContext::AppUnitsToDoubleCSSPixels(aItem->mFrameRect.X()),
|
||||
nsPresContext::AppUnitsToDoubleCSSPixels(aItem->mFrameRect.Y()),
|
||||
nsPresContext::AppUnitsToDoubleCSSPixels(aItem->mFrameRect.Width()),
|
||||
nsPresContext::AppUnitsToDoubleCSSPixels(aItem->mFrameRect.Height()));
|
||||
|
||||
// Convert app unit sizes to css pixel sizes.
|
||||
mMainBaseSize = nsPresContext::AppUnitsToDoubleCSSPixels(
|
||||
aItem->mMainBaseSize);
|
||||
|
@ -76,6 +85,12 @@ FlexItemValues::GetNode() const
|
|||
return mNode;
|
||||
}
|
||||
|
||||
DOMRectReadOnly*
|
||||
FlexItemValues::FrameRect() const
|
||||
{
|
||||
return mFrameRect;
|
||||
}
|
||||
|
||||
double
|
||||
FlexItemValues::MainBaseSize() const
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
}
|
||||
|
||||
nsINode* GetNode() const;
|
||||
DOMRectReadOnly* FrameRect() const;
|
||||
double MainBaseSize() const;
|
||||
double MainDeltaSize() const;
|
||||
double MainMinSize() const;
|
||||
|
@ -50,6 +51,7 @@ public:
|
|||
protected:
|
||||
RefPtr<FlexLineValues> mParent;
|
||||
RefPtr<nsINode> mNode;
|
||||
RefPtr<DOMRectReadOnly> mFrameRect;
|
||||
|
||||
// These sizes are all CSS pixel units.
|
||||
double mMainBaseSize;
|
||||
|
|
|
@ -4849,14 +4849,9 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
|
|||
|
||||
itemInfo->mNode = content;
|
||||
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5261,7 +5256,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;
|
||||
|
@ -5271,6 +5266,17 @@ 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.mFrameRect = item->Frame()->GetRect();
|
||||
itemInfo.mMainMinSize = item->GetMainMinSize();
|
||||
itemInfo.mMainMaxSize = item->GetMainMaxSize();
|
||||
itemInfo.mCrossMinSize = item->GetCrossMinSize();
|
||||
itemInfo.mCrossMaxSize = item->GetCrossMaxSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ nsContainerFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
|
|||
struct ComputedFlexItemInfo
|
||||
{
|
||||
nsCOMPtr<nsINode> mNode;
|
||||
nsRect mFrameRect;
|
||||
/**
|
||||
* mMainBaseSize is a measure of the size of the item in the main
|
||||
* axis before the flex sizing algorithm is applied. In the spec,
|
||||
|
|
Загрузка…
Ссылка в новой задаче