зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1155772 Part 7 - Convert FlexItem::mBorderPadding from nsMargin to LogicalMargin. r=mats
Also delete unused GetBorderPadding(). Differential Revision: https://phabricator.services.mozilla.com/D59049 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
03f6d42e78
Коммит
a94c944d4f
|
@ -517,12 +517,14 @@ class nsFlexContainerFrame::FlexItem : public LinkedListElement<FlexItem> {
|
|||
// Convenience methods to compute the main & cross size of our *margin-box*.
|
||||
// The caller is responsible for telling us the right axis, so that we can
|
||||
// pull out the appropriate components of our margin/border/padding structs.
|
||||
// FIXME(TYLin): The AxisOrientationType argument can be removed after
|
||||
// converting mMargin to LogicalMargin.
|
||||
nscoord GetOuterMainSize(AxisOrientationType aMainAxis) const {
|
||||
return mMainSize + GetMarginBorderPaddingSizeInAxis(aMainAxis);
|
||||
return mMainSize + GetMarginBorderPaddingSizeInMainAxis(aMainAxis);
|
||||
}
|
||||
|
||||
nscoord GetOuterCrossSize(AxisOrientationType aCrossAxis) const {
|
||||
return mCrossSize + GetMarginBorderPaddingSizeInAxis(aCrossAxis);
|
||||
return mCrossSize + GetMarginBorderPaddingSizeInCrossAxis(aCrossAxis);
|
||||
}
|
||||
|
||||
// Returns the distance between this FlexItem's baseline and the cross-start
|
||||
|
@ -665,29 +667,28 @@ class nsFlexContainerFrame::FlexItem : public LinkedListElement<FlexItem> {
|
|||
|
||||
// Getters for border/padding
|
||||
// ==========================
|
||||
const nsMargin& GetBorderPadding() const { return mBorderPadding; }
|
||||
|
||||
// Returns the border+padding component for a given mozilla::Side
|
||||
nscoord GetBorderPaddingComponentForSide(mozilla::Side aSide) const {
|
||||
return mBorderPadding.Side(aSide);
|
||||
}
|
||||
|
||||
// Returns the total space occupied by this item's borders and padding in
|
||||
// the given axis
|
||||
nscoord GetBorderPaddingSizeInAxis(AxisOrientationType aAxis) const {
|
||||
mozilla::Side startSide =
|
||||
kAxisOrientationToSidesMap[aAxis][eAxisEdge_Start];
|
||||
mozilla::Side endSide = kAxisOrientationToSidesMap[aAxis][eAxisEdge_End];
|
||||
return GetBorderPaddingComponentForSide(startSide) +
|
||||
GetBorderPaddingComponentForSide(endSide);
|
||||
nscoord GetBorderPaddingSizeInMainAxis() const {
|
||||
return mBorderPadding.StartEnd(MainAxis(), mCBWM);
|
||||
}
|
||||
nscoord GetBorderPaddingSizeInCrossAxis() const {
|
||||
return mBorderPadding.StartEnd(CrossAxis(), mCBWM);
|
||||
}
|
||||
|
||||
// Getter for combined margin/border/padding
|
||||
// =========================================
|
||||
// Returns the total space occupied by this item's margins, borders and
|
||||
// padding in the given axis
|
||||
nscoord GetMarginBorderPaddingSizeInAxis(AxisOrientationType aAxis) const {
|
||||
return GetMarginSizeInAxis(aAxis) + GetBorderPaddingSizeInAxis(aAxis);
|
||||
// FIXME(TYLin): The AxisOrientationType argument can be removed after
|
||||
// converting mMargin to LogicalMargin.
|
||||
nscoord GetMarginBorderPaddingSizeInMainAxis(
|
||||
AxisOrientationType aAxis) const {
|
||||
return GetMarginSizeInAxis(aAxis) + GetBorderPaddingSizeInMainAxis();
|
||||
}
|
||||
nscoord GetMarginBorderPaddingSizeInCrossAxis(
|
||||
AxisOrientationType aAxis) const {
|
||||
return GetMarginSizeInAxis(aAxis) + GetBorderPaddingSizeInCrossAxis();
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
@ -877,7 +878,8 @@ class nsFlexContainerFrame::FlexItem : public LinkedListElement<FlexItem> {
|
|||
// The flex container's main axis in flex container's writing mode.
|
||||
const LogicalAxis mMainAxis = eLogicalAxisInline;
|
||||
|
||||
const nsMargin mBorderPadding;
|
||||
// Stored in flex container's writing mode.
|
||||
const LogicalMargin mBorderPadding;
|
||||
// Non-const because we need to resolve auto margins.
|
||||
nsMargin mMargin;
|
||||
|
||||
|
@ -1920,7 +1922,9 @@ FlexItem::FlexItem(ReflowInput& aFlexItemReflowInput, float aFlexGrow,
|
|||
mWM(aFlexItemReflowInput.GetWritingMode()),
|
||||
mCBWM(aAxisTracker.GetWritingMode()),
|
||||
mMainAxis(aAxisTracker.MainAxis()),
|
||||
mBorderPadding(aFlexItemReflowInput.ComputedPhysicalBorderPadding()),
|
||||
mBorderPadding(
|
||||
aFlexItemReflowInput.ComputedLogicalBorderPadding().ConvertTo(mCBWM,
|
||||
mWM)),
|
||||
mMargin(aFlexItemReflowInput.ComputedPhysicalMargin()),
|
||||
mMainMinSize(aMainMinSize),
|
||||
mMainMaxSize(aMainMaxSize),
|
||||
|
@ -2061,6 +2065,7 @@ FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize,
|
|||
: mFrame(aChildFrame),
|
||||
mWM(aContainerWM),
|
||||
mCBWM(aContainerWM),
|
||||
mBorderPadding(mCBWM),
|
||||
mCrossSize(aCrossSize),
|
||||
// Struts don't do layout, so its WM doesn't matter at this point. So, we
|
||||
// just share container's WM for simplicity:
|
||||
|
@ -3448,7 +3453,7 @@ void FlexItem::ResolveStretchedCrossSize(
|
|||
// Reserve space for margins & border & padding, and then use whatever
|
||||
// remains as our item's cross-size (clamped to its min/max range).
|
||||
nscoord stretchedSize =
|
||||
aLineCrossSize - GetMarginBorderPaddingSizeInAxis(crossAxis);
|
||||
aLineCrossSize - GetMarginBorderPaddingSizeInCrossAxis(crossAxis);
|
||||
|
||||
stretchedSize = NS_CSS_MINMAX(stretchedSize, mCrossMinSize, mCrossMaxSize);
|
||||
|
||||
|
@ -4186,8 +4191,7 @@ void FlexLine::PositionItemsInMainAxis(uint8_t aJustifyContent,
|
|||
aAxisTracker, this, aJustifyContent, aContentBoxMainSize);
|
||||
for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) {
|
||||
nscoord itemMainBorderBoxSize =
|
||||
item->GetMainSize() +
|
||||
item->GetBorderPaddingSizeInAxis(mainAxisPosnTracker.GetPhysicalAxis());
|
||||
item->GetMainSize() + item->GetBorderPaddingSizeInMainAxis();
|
||||
|
||||
// Resolve any main-axis 'auto' margins on aChild to an actual value.
|
||||
mainAxisPosnTracker.ResolveAutoMarginsInMainAxis(*item);
|
||||
|
@ -4223,9 +4227,9 @@ static nscoord ComputePhysicalAscentFromFlexRelativeAscent(
|
|||
aAxisTracker.GetPhysicalCrossAxis());
|
||||
}
|
||||
|
||||
void nsFlexContainerFrame::SizeItemInCrossAxis(
|
||||
nsPresContext* aPresContext, const FlexboxAxisTracker& aAxisTracker,
|
||||
ReflowInput& aChildReflowInput, FlexItem& aItem) {
|
||||
void nsFlexContainerFrame::SizeItemInCrossAxis(nsPresContext* aPresContext,
|
||||
ReflowInput& aChildReflowInput,
|
||||
FlexItem& aItem) {
|
||||
// If cross axis is the item's inline axis, just use ISize from reflow input,
|
||||
// and don't bother with a full reflow.
|
||||
if (aItem.IsInlineAxisCrossAxis()) {
|
||||
|
@ -4259,8 +4263,7 @@ void nsFlexContainerFrame::SizeItemInCrossAxis(
|
|||
// Tentatively store the child's desired content-box cross-size.
|
||||
// Note that childDesiredSize is the border-box size, so we have to
|
||||
// subtract border & padding to get the content-box size.
|
||||
nscoord crossAxisBorderPadding =
|
||||
aItem.GetBorderPaddingSizeInAxis(aAxisTracker.GetPhysicalCrossAxis());
|
||||
nscoord crossAxisBorderPadding = aItem.GetBorderPaddingSizeInCrossAxis();
|
||||
if (reflowResult.BSize() < crossAxisBorderPadding) {
|
||||
// Child's requested size isn't large enough for its border/padding!
|
||||
// This is OK for the trivial nsFrame::Reflow() impl, but other frame
|
||||
|
@ -4292,8 +4295,7 @@ void FlexLine::PositionItemsInCrossAxis(
|
|||
|
||||
// Compute the cross-axis position of this item
|
||||
nscoord itemCrossBorderBoxSize =
|
||||
item->GetCrossSize() +
|
||||
item->GetBorderPaddingSizeInAxis(aAxisTracker.GetPhysicalCrossAxis());
|
||||
item->GetCrossSize() + item->GetBorderPaddingSizeInCrossAxis();
|
||||
lineCrossAxisPosnTracker.EnterAlignPackingSpace(*this, *item, aAxisTracker);
|
||||
lineCrossAxisPosnTracker.EnterMargin(item->GetMargin());
|
||||
lineCrossAxisPosnTracker.EnterChildFrame(itemCrossBorderBoxSize);
|
||||
|
@ -4405,9 +4407,8 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
|
|||
// instead of using this class.)
|
||||
class MOZ_RAII AutoFlexItemMainSizeOverride final {
|
||||
public:
|
||||
explicit AutoFlexItemMainSizeOverride(FlexItem& aItem,
|
||||
const FlexboxAxisTracker& aAxisTracker
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
explicit AutoFlexItemMainSizeOverride(
|
||||
FlexItem& aItem MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mItemFrame(aItem.Frame()) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
||||
|
@ -4423,8 +4424,7 @@ class MOZ_RAII AutoFlexItemMainSizeOverride final {
|
|||
// and padding in order to produce an appopriate "override" value that
|
||||
// gets us the content-box size that we expect.
|
||||
if (aItem.Frame()->StylePosition()->mBoxSizing == StyleBoxSizing::Border) {
|
||||
mainSizeOverrideVal +=
|
||||
aItem.GetBorderPaddingSizeInAxis(aAxisTracker.GetPhysicalMainAxis());
|
||||
mainSizeOverrideVal += aItem.GetBorderPaddingSizeInMainAxis();
|
||||
}
|
||||
|
||||
mItemFrame->SetProperty(nsIFrame::FlexItemMainSizeOverride(),
|
||||
|
@ -4792,7 +4792,7 @@ void nsFlexContainerFrame::DoFlexLayout(
|
|||
// (and cheaper) to impose our main size *after* the reflow input has
|
||||
// been constructed, since the main size shouldn't influence anything
|
||||
// about cross-size measurement until we actually reflow the child.)
|
||||
sizeOverride.emplace(*item, aAxisTracker);
|
||||
sizeOverride.emplace(*item);
|
||||
}
|
||||
|
||||
WritingMode wm = item->Frame()->GetWritingMode();
|
||||
|
@ -4813,8 +4813,7 @@ void nsFlexContainerFrame::DoFlexLayout(
|
|||
}
|
||||
}
|
||||
|
||||
SizeItemInCrossAxis(aPresContext, aAxisTracker, childReflowInput,
|
||||
*item);
|
||||
SizeItemInCrossAxis(aPresContext, childReflowInput, *item);
|
||||
}
|
||||
}
|
||||
// Now that we've finished with this line's items, size the line itself:
|
||||
|
|
|
@ -398,7 +398,6 @@ class nsFlexContainerFrame final : public nsContainerFrame {
|
|||
nsReflowStatus& aStatus);
|
||||
|
||||
void SizeItemInCrossAxis(nsPresContext* aPresContext,
|
||||
const FlexboxAxisTracker& aAxisTracker,
|
||||
ReflowInput& aChildReflowInput, FlexItem& aItem);
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче