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:
Ting-Yu Lin 2020-01-21 20:30:26 +00:00
Родитель 03f6d42e78
Коммит a94c944d4f
2 изменённых файлов: 36 добавлений и 38 удалений

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

@ -517,12 +517,14 @@ class nsFlexContainerFrame::FlexItem : public LinkedListElement<FlexItem> {
// Convenience methods to compute the main & cross size of our *margin-box*. // 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 // 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. // 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 { nscoord GetOuterMainSize(AxisOrientationType aMainAxis) const {
return mMainSize + GetMarginBorderPaddingSizeInAxis(aMainAxis); return mMainSize + GetMarginBorderPaddingSizeInMainAxis(aMainAxis);
} }
nscoord GetOuterCrossSize(AxisOrientationType aCrossAxis) const { 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 // 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 // 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 // Returns the total space occupied by this item's borders and padding in
// the given axis // the given axis
nscoord GetBorderPaddingSizeInAxis(AxisOrientationType aAxis) const { nscoord GetBorderPaddingSizeInMainAxis() const {
mozilla::Side startSide = return mBorderPadding.StartEnd(MainAxis(), mCBWM);
kAxisOrientationToSidesMap[aAxis][eAxisEdge_Start]; }
mozilla::Side endSide = kAxisOrientationToSidesMap[aAxis][eAxisEdge_End]; nscoord GetBorderPaddingSizeInCrossAxis() const {
return GetBorderPaddingComponentForSide(startSide) + return mBorderPadding.StartEnd(CrossAxis(), mCBWM);
GetBorderPaddingComponentForSide(endSide);
} }
// Getter for combined margin/border/padding // Getter for combined margin/border/padding
// ========================================= // =========================================
// Returns the total space occupied by this item's margins, borders and // Returns the total space occupied by this item's margins, borders and
// padding in the given axis // padding in the given axis
nscoord GetMarginBorderPaddingSizeInAxis(AxisOrientationType aAxis) const { // FIXME(TYLin): The AxisOrientationType argument can be removed after
return GetMarginSizeInAxis(aAxis) + GetBorderPaddingSizeInAxis(aAxis); // converting mMargin to LogicalMargin.
nscoord GetMarginBorderPaddingSizeInMainAxis(
AxisOrientationType aAxis) const {
return GetMarginSizeInAxis(aAxis) + GetBorderPaddingSizeInMainAxis();
}
nscoord GetMarginBorderPaddingSizeInCrossAxis(
AxisOrientationType aAxis) const {
return GetMarginSizeInAxis(aAxis) + GetBorderPaddingSizeInCrossAxis();
} }
// Setters // Setters
@ -877,7 +878,8 @@ class nsFlexContainerFrame::FlexItem : public LinkedListElement<FlexItem> {
// The flex container's main axis in flex container's writing mode. // The flex container's main axis in flex container's writing mode.
const LogicalAxis mMainAxis = eLogicalAxisInline; 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. // Non-const because we need to resolve auto margins.
nsMargin mMargin; nsMargin mMargin;
@ -1920,7 +1922,9 @@ FlexItem::FlexItem(ReflowInput& aFlexItemReflowInput, float aFlexGrow,
mWM(aFlexItemReflowInput.GetWritingMode()), mWM(aFlexItemReflowInput.GetWritingMode()),
mCBWM(aAxisTracker.GetWritingMode()), mCBWM(aAxisTracker.GetWritingMode()),
mMainAxis(aAxisTracker.MainAxis()), mMainAxis(aAxisTracker.MainAxis()),
mBorderPadding(aFlexItemReflowInput.ComputedPhysicalBorderPadding()), mBorderPadding(
aFlexItemReflowInput.ComputedLogicalBorderPadding().ConvertTo(mCBWM,
mWM)),
mMargin(aFlexItemReflowInput.ComputedPhysicalMargin()), mMargin(aFlexItemReflowInput.ComputedPhysicalMargin()),
mMainMinSize(aMainMinSize), mMainMinSize(aMainMinSize),
mMainMaxSize(aMainMaxSize), mMainMaxSize(aMainMaxSize),
@ -2061,6 +2065,7 @@ FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize,
: mFrame(aChildFrame), : mFrame(aChildFrame),
mWM(aContainerWM), mWM(aContainerWM),
mCBWM(aContainerWM), mCBWM(aContainerWM),
mBorderPadding(mCBWM),
mCrossSize(aCrossSize), mCrossSize(aCrossSize),
// Struts don't do layout, so its WM doesn't matter at this point. So, we // Struts don't do layout, so its WM doesn't matter at this point. So, we
// just share container's WM for simplicity: // just share container's WM for simplicity:
@ -3448,7 +3453,7 @@ void FlexItem::ResolveStretchedCrossSize(
// Reserve space for margins & border & padding, and then use whatever // Reserve space for margins & border & padding, and then use whatever
// remains as our item's cross-size (clamped to its min/max range). // remains as our item's cross-size (clamped to its min/max range).
nscoord stretchedSize = nscoord stretchedSize =
aLineCrossSize - GetMarginBorderPaddingSizeInAxis(crossAxis); aLineCrossSize - GetMarginBorderPaddingSizeInCrossAxis(crossAxis);
stretchedSize = NS_CSS_MINMAX(stretchedSize, mCrossMinSize, mCrossMaxSize); stretchedSize = NS_CSS_MINMAX(stretchedSize, mCrossMinSize, mCrossMaxSize);
@ -4186,8 +4191,7 @@ void FlexLine::PositionItemsInMainAxis(uint8_t aJustifyContent,
aAxisTracker, this, aJustifyContent, aContentBoxMainSize); aAxisTracker, this, aJustifyContent, aContentBoxMainSize);
for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) { for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) {
nscoord itemMainBorderBoxSize = nscoord itemMainBorderBoxSize =
item->GetMainSize() + item->GetMainSize() + item->GetBorderPaddingSizeInMainAxis();
item->GetBorderPaddingSizeInAxis(mainAxisPosnTracker.GetPhysicalAxis());
// Resolve any main-axis 'auto' margins on aChild to an actual value. // Resolve any main-axis 'auto' margins on aChild to an actual value.
mainAxisPosnTracker.ResolveAutoMarginsInMainAxis(*item); mainAxisPosnTracker.ResolveAutoMarginsInMainAxis(*item);
@ -4223,9 +4227,9 @@ static nscoord ComputePhysicalAscentFromFlexRelativeAscent(
aAxisTracker.GetPhysicalCrossAxis()); aAxisTracker.GetPhysicalCrossAxis());
} }
void nsFlexContainerFrame::SizeItemInCrossAxis( void nsFlexContainerFrame::SizeItemInCrossAxis(nsPresContext* aPresContext,
nsPresContext* aPresContext, const FlexboxAxisTracker& aAxisTracker, ReflowInput& aChildReflowInput,
ReflowInput& aChildReflowInput, FlexItem& aItem) { FlexItem& aItem) {
// If cross axis is the item's inline axis, just use ISize from reflow input, // If cross axis is the item's inline axis, just use ISize from reflow input,
// and don't bother with a full reflow. // and don't bother with a full reflow.
if (aItem.IsInlineAxisCrossAxis()) { if (aItem.IsInlineAxisCrossAxis()) {
@ -4259,8 +4263,7 @@ void nsFlexContainerFrame::SizeItemInCrossAxis(
// Tentatively store the child's desired content-box cross-size. // Tentatively store the child's desired content-box cross-size.
// Note that childDesiredSize is the border-box size, so we have to // Note that childDesiredSize is the border-box size, so we have to
// subtract border & padding to get the content-box size. // subtract border & padding to get the content-box size.
nscoord crossAxisBorderPadding = nscoord crossAxisBorderPadding = aItem.GetBorderPaddingSizeInCrossAxis();
aItem.GetBorderPaddingSizeInAxis(aAxisTracker.GetPhysicalCrossAxis());
if (reflowResult.BSize() < crossAxisBorderPadding) { if (reflowResult.BSize() < crossAxisBorderPadding) {
// Child's requested size isn't large enough for its border/padding! // Child's requested size isn't large enough for its border/padding!
// This is OK for the trivial nsFrame::Reflow() impl, but other frame // 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 // Compute the cross-axis position of this item
nscoord itemCrossBorderBoxSize = nscoord itemCrossBorderBoxSize =
item->GetCrossSize() + item->GetCrossSize() + item->GetBorderPaddingSizeInCrossAxis();
item->GetBorderPaddingSizeInAxis(aAxisTracker.GetPhysicalCrossAxis());
lineCrossAxisPosnTracker.EnterAlignPackingSpace(*this, *item, aAxisTracker); lineCrossAxisPosnTracker.EnterAlignPackingSpace(*this, *item, aAxisTracker);
lineCrossAxisPosnTracker.EnterMargin(item->GetMargin()); lineCrossAxisPosnTracker.EnterMargin(item->GetMargin());
lineCrossAxisPosnTracker.EnterChildFrame(itemCrossBorderBoxSize); lineCrossAxisPosnTracker.EnterChildFrame(itemCrossBorderBoxSize);
@ -4405,9 +4407,8 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
// instead of using this class.) // instead of using this class.)
class MOZ_RAII AutoFlexItemMainSizeOverride final { class MOZ_RAII AutoFlexItemMainSizeOverride final {
public: public:
explicit AutoFlexItemMainSizeOverride(FlexItem& aItem, explicit AutoFlexItemMainSizeOverride(
const FlexboxAxisTracker& aAxisTracker FlexItem& aItem MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mItemFrame(aItem.Frame()) { : mItemFrame(aItem.Frame()) {
MOZ_GUARD_OBJECT_NOTIFIER_INIT; 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 // and padding in order to produce an appopriate "override" value that
// gets us the content-box size that we expect. // gets us the content-box size that we expect.
if (aItem.Frame()->StylePosition()->mBoxSizing == StyleBoxSizing::Border) { if (aItem.Frame()->StylePosition()->mBoxSizing == StyleBoxSizing::Border) {
mainSizeOverrideVal += mainSizeOverrideVal += aItem.GetBorderPaddingSizeInMainAxis();
aItem.GetBorderPaddingSizeInAxis(aAxisTracker.GetPhysicalMainAxis());
} }
mItemFrame->SetProperty(nsIFrame::FlexItemMainSizeOverride(), mItemFrame->SetProperty(nsIFrame::FlexItemMainSizeOverride(),
@ -4792,7 +4792,7 @@ void nsFlexContainerFrame::DoFlexLayout(
// (and cheaper) to impose our main size *after* the reflow input has // (and cheaper) to impose our main size *after* the reflow input has
// been constructed, since the main size shouldn't influence anything // been constructed, since the main size shouldn't influence anything
// about cross-size measurement until we actually reflow the child.) // about cross-size measurement until we actually reflow the child.)
sizeOverride.emplace(*item, aAxisTracker); sizeOverride.emplace(*item);
} }
WritingMode wm = item->Frame()->GetWritingMode(); WritingMode wm = item->Frame()->GetWritingMode();
@ -4813,8 +4813,7 @@ void nsFlexContainerFrame::DoFlexLayout(
} }
} }
SizeItemInCrossAxis(aPresContext, aAxisTracker, childReflowInput, SizeItemInCrossAxis(aPresContext, childReflowInput, *item);
*item);
} }
} }
// Now that we've finished with this line's items, size the line itself: // 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); nsReflowStatus& aStatus);
void SizeItemInCrossAxis(nsPresContext* aPresContext, void SizeItemInCrossAxis(nsPresContext* aPresContext,
const FlexboxAxisTracker& aAxisTracker,
ReflowInput& aChildReflowInput, FlexItem& aItem); ReflowInput& aChildReflowInput, FlexItem& aItem);
/** /**