зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1588017 - Clean up nsIFrame::IntrinsicISizeOffsetData r=TYLin,dholbert
Update the comments, name, and fields to show it is agnostic of isize/bsize. Differential Revision: https://phabricator.services.mozilla.com/D51739 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1d1cb3bdf1
Коммит
43cc243866
|
@ -5197,7 +5197,7 @@ static bool IsReplacedBoxResolvedAgainstZero(
|
|||
*/
|
||||
static nscoord AddIntrinsicSizeOffset(
|
||||
gfxContext* aRenderingContext, nsIFrame* aFrame,
|
||||
const nsIFrame::IntrinsicISizeOffsetData& aOffsets,
|
||||
const nsIFrame::IntrinsicSizeOffsetData& aOffsets,
|
||||
nsLayoutUtils::IntrinsicISizeType aType, StyleBoxSizing aBoxSizing,
|
||||
nscoord aContentSize, nscoord aContentMinSize, const StyleSize& aStyleSize,
|
||||
const nscoord* aFixedMinSize, const StyleSize& aStyleMinSize,
|
||||
|
@ -5208,10 +5208,10 @@ static nscoord AddIntrinsicSizeOffset(
|
|||
nscoord coordOutsideSize = 0;
|
||||
|
||||
if (!(aFlags & nsLayoutUtils::IGNORE_PADDING)) {
|
||||
coordOutsideSize += aOffsets.hPadding;
|
||||
coordOutsideSize += aOffsets.padding;
|
||||
}
|
||||
|
||||
coordOutsideSize += aOffsets.hBorder;
|
||||
coordOutsideSize += aOffsets.border;
|
||||
|
||||
if (aBoxSizing == StyleBoxSizing::Border) {
|
||||
min += coordOutsideSize;
|
||||
|
@ -5220,7 +5220,7 @@ static nscoord AddIntrinsicSizeOffset(
|
|||
coordOutsideSize = 0;
|
||||
}
|
||||
|
||||
coordOutsideSize += aOffsets.hMargin;
|
||||
coordOutsideSize += aOffsets.margin;
|
||||
|
||||
min += coordOutsideSize;
|
||||
result = NSCoordSaturatingAdd(result, coordOutsideSize);
|
||||
|
@ -5268,7 +5268,7 @@ static nscoord AddIntrinsicSizeOffset(
|
|||
nscoord themeSize = pc->DevPixelsToAppUnits(
|
||||
aAxis == eAxisVertical ? devSize.height : devSize.width);
|
||||
// GetMinimumWidgetSize() returns a border-box width.
|
||||
themeSize += aOffsets.hMargin;
|
||||
themeSize += aOffsets.margin;
|
||||
if (themeSize > result || !canOverride) {
|
||||
result = themeSize;
|
||||
}
|
||||
|
@ -5541,7 +5541,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
|||
? aPercentageBasis->BSize(childWM)
|
||||
: aPercentageBasis->ISize(childWM);
|
||||
}
|
||||
nsIFrame::IntrinsicISizeOffsetData offsets =
|
||||
nsIFrame::IntrinsicSizeOffsetData offsets =
|
||||
MOZ_LIKELY(isInlineAxis)
|
||||
? aFrame->IntrinsicISizeOffsets(pmPercentageBasis)
|
||||
: aFrame->IntrinsicBSizeOffsets(pmPercentageBasis);
|
||||
|
@ -5674,7 +5674,7 @@ nscoord nsLayoutUtils::MinSizeContributionForAxis(
|
|||
aFrame->GetParent()->GetWritingMode().IsOrthogonalTo(childWM)
|
||||
? aPercentageBasis.BSize(childWM)
|
||||
: aPercentageBasis.ISize(childWM);
|
||||
nsIFrame::IntrinsicISizeOffsetData offsets =
|
||||
nsIFrame::IntrinsicSizeOffsetData offsets =
|
||||
ourInlineAxis == aAxis ? aFrame->IntrinsicISizeOffsets(pmPercentageBasis)
|
||||
: aFrame->IntrinsicBSizeOffsets(pmPercentageBasis);
|
||||
nscoord result = 0;
|
||||
|
|
|
@ -721,10 +721,8 @@ nscoord nsComboboxControlFrame::GetIntrinsicISize(
|
|||
nscoord displayISize = 0;
|
||||
if (MOZ_LIKELY(mDisplayFrame)) {
|
||||
if (isContainSize) {
|
||||
// Note: the "h" in "hPadding" here really means "inline-axis".
|
||||
// Its struct uses "h" prefixes for historical reasons, but they're all
|
||||
// for the inline-axis, not (necessarily) the horizontal axis.
|
||||
displayISize = mDisplayFrame->IntrinsicISizeOffsets().hPadding;
|
||||
// Get padding from the inline-axis
|
||||
displayISize = mDisplayFrame->IntrinsicISizeOffsets().padding;
|
||||
} else {
|
||||
displayISize = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
||||
mDisplayFrame, aType);
|
||||
|
|
|
@ -5730,38 +5730,37 @@ static nscoord ResolvePadding(const LengthPercentage& aStyle,
|
|||
return nsLayoutUtils::ResolveToLength<true>(aStyle, aPercentageBasis);
|
||||
}
|
||||
|
||||
static nsIFrame::IntrinsicISizeOffsetData IntrinsicSizeOffsets(
|
||||
static nsIFrame::IntrinsicSizeOffsetData IntrinsicSizeOffsets(
|
||||
nsIFrame* aFrame, nscoord aPercentageBasis, bool aForISize) {
|
||||
nsIFrame::IntrinsicISizeOffsetData result;
|
||||
nsIFrame::IntrinsicSizeOffsetData result;
|
||||
WritingMode wm = aFrame->GetWritingMode();
|
||||
const auto& margin = aFrame->StyleMargin()->mMargin;
|
||||
bool verticalAxis = aForISize == wm.IsVertical();
|
||||
if (verticalAxis) {
|
||||
result.hMargin += ResolveMargin(margin.Get(eSideTop), aPercentageBasis);
|
||||
result.hMargin += ResolveMargin(margin.Get(eSideBottom), aPercentageBasis);
|
||||
result.margin += ResolveMargin(margin.Get(eSideTop), aPercentageBasis);
|
||||
result.margin += ResolveMargin(margin.Get(eSideBottom), aPercentageBasis);
|
||||
} else {
|
||||
result.hMargin += ResolveMargin(margin.Get(eSideLeft), aPercentageBasis);
|
||||
result.hMargin += ResolveMargin(margin.Get(eSideRight), aPercentageBasis);
|
||||
result.margin += ResolveMargin(margin.Get(eSideLeft), aPercentageBasis);
|
||||
result.margin += ResolveMargin(margin.Get(eSideRight), aPercentageBasis);
|
||||
}
|
||||
|
||||
const auto& padding = aFrame->StylePadding()->mPadding;
|
||||
if (verticalAxis) {
|
||||
result.hPadding += ResolvePadding(padding.Get(eSideTop), aPercentageBasis);
|
||||
result.hPadding +=
|
||||
result.padding += ResolvePadding(padding.Get(eSideTop), aPercentageBasis);
|
||||
result.padding +=
|
||||
ResolvePadding(padding.Get(eSideBottom), aPercentageBasis);
|
||||
} else {
|
||||
result.hPadding += ResolvePadding(padding.Get(eSideLeft), aPercentageBasis);
|
||||
result.hPadding +=
|
||||
ResolvePadding(padding.Get(eSideRight), aPercentageBasis);
|
||||
result.padding += ResolvePadding(padding.Get(eSideLeft), aPercentageBasis);
|
||||
result.padding += ResolvePadding(padding.Get(eSideRight), aPercentageBasis);
|
||||
}
|
||||
|
||||
const nsStyleBorder* styleBorder = aFrame->StyleBorder();
|
||||
if (verticalAxis) {
|
||||
result.hBorder += styleBorder->GetComputedBorderWidth(eSideTop);
|
||||
result.hBorder += styleBorder->GetComputedBorderWidth(eSideBottom);
|
||||
result.border += styleBorder->GetComputedBorderWidth(eSideTop);
|
||||
result.border += styleBorder->GetComputedBorderWidth(eSideBottom);
|
||||
} else {
|
||||
result.hBorder += styleBorder->GetComputedBorderWidth(eSideLeft);
|
||||
result.hBorder += styleBorder->GetComputedBorderWidth(eSideRight);
|
||||
result.border += styleBorder->GetComputedBorderWidth(eSideLeft);
|
||||
result.border += styleBorder->GetComputedBorderWidth(eSideRight);
|
||||
}
|
||||
|
||||
const nsStyleDisplay* disp = aFrame->StyleDisplay();
|
||||
|
@ -5770,26 +5769,26 @@ static nsIFrame::IntrinsicISizeOffsetData IntrinsicSizeOffsets(
|
|||
|
||||
LayoutDeviceIntMargin border = presContext->GetTheme()->GetWidgetBorder(
|
||||
presContext->DeviceContext(), aFrame, disp->mAppearance);
|
||||
result.hBorder = presContext->DevPixelsToAppUnits(
|
||||
result.border = presContext->DevPixelsToAppUnits(
|
||||
verticalAxis ? border.TopBottom() : border.LeftRight());
|
||||
|
||||
LayoutDeviceIntMargin padding;
|
||||
if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
|
||||
aFrame, disp->mAppearance,
|
||||
&padding)) {
|
||||
result.hPadding = presContext->DevPixelsToAppUnits(
|
||||
result.padding = presContext->DevPixelsToAppUnits(
|
||||
verticalAxis ? padding.TopBottom() : padding.LeftRight());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* virtual */ nsIFrame::IntrinsicISizeOffsetData nsFrame::IntrinsicISizeOffsets(
|
||||
/* virtual */ nsIFrame::IntrinsicSizeOffsetData nsFrame::IntrinsicISizeOffsets(
|
||||
nscoord aPercentageBasis) {
|
||||
return IntrinsicSizeOffsets(this, aPercentageBasis, true);
|
||||
}
|
||||
|
||||
nsIFrame::IntrinsicISizeOffsetData nsIFrame::IntrinsicBSizeOffsets(
|
||||
nsIFrame::IntrinsicSizeOffsetData nsIFrame::IntrinsicBSizeOffsets(
|
||||
nscoord aPercentageBasis) {
|
||||
return IntrinsicSizeOffsets(this, aPercentageBasis, false);
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ class nsFrame : public nsBox {
|
|||
InlineMinISizeData* aData) override;
|
||||
void AddInlinePrefISize(gfxContext* aRenderingContext,
|
||||
InlinePrefISizeData* aData) override;
|
||||
IntrinsicISizeOffsetData IntrinsicISizeOffsets(
|
||||
IntrinsicSizeOffsetData IntrinsicISizeOffsets(
|
||||
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE) override;
|
||||
mozilla::IntrinsicSize GetIntrinsicSize() override;
|
||||
mozilla::AspectRatio GetIntrinsicRatio() override;
|
||||
|
|
|
@ -2358,17 +2358,23 @@ class nsIFrame : public nsQueryFrame {
|
|||
InlinePrefISizeData* aData) = 0;
|
||||
|
||||
/**
|
||||
* Return the horizontal components of padding, border, and margin
|
||||
* Intrinsic size of a frame in a single axis.
|
||||
*
|
||||
* This can represent either isize or bsize.
|
||||
*/
|
||||
struct IntrinsicSizeOffsetData {
|
||||
nscoord padding = 0;
|
||||
nscoord border = 0;
|
||||
nscoord margin = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the isize components of padding, border, and margin
|
||||
* that contribute to the intrinsic width that applies to the parent.
|
||||
* @param aPercentageBasis the percentage basis to use for padding/margin -
|
||||
* i.e. the Containing Block's inline-size
|
||||
*/
|
||||
struct IntrinsicISizeOffsetData {
|
||||
nscoord hPadding, hBorder, hMargin;
|
||||
|
||||
IntrinsicISizeOffsetData() : hPadding(0), hBorder(0), hMargin(0) {}
|
||||
};
|
||||
virtual IntrinsicISizeOffsetData IntrinsicISizeOffsets(
|
||||
virtual IntrinsicSizeOffsetData IntrinsicISizeOffsets(
|
||||
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE) = 0;
|
||||
|
||||
/**
|
||||
|
@ -2377,7 +2383,7 @@ class nsIFrame : public nsQueryFrame {
|
|||
* @param aPercentageBasis the percentage basis to use for padding/margin -
|
||||
* i.e. the Containing Block's inline-size
|
||||
*/
|
||||
IntrinsicISizeOffsetData IntrinsicBSizeOffsets(
|
||||
IntrinsicSizeOffsetData IntrinsicBSizeOffsets(
|
||||
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE);
|
||||
|
||||
virtual mozilla::IntrinsicSize GetIntrinsicSize() = 0;
|
||||
|
|
|
@ -98,8 +98,7 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
|
|||
// outer edges near the end of this function.
|
||||
|
||||
// XXX Should we ignore percentage padding?
|
||||
nsIFrame::IntrinsicISizeOffsetData offsets =
|
||||
aFrame->IntrinsicISizeOffsets();
|
||||
nsIFrame::IntrinsicSizeOffsetData offsets = aFrame->IntrinsicISizeOffsets();
|
||||
|
||||
// In quirks mode, table cell isize should be content-box,
|
||||
// but bsize should be border box.
|
||||
|
@ -109,11 +108,11 @@ static CellISizeInfo GetISizeInfo(gfxContext* aRenderingContext,
|
|||
// For this reason, we also do not use box-sizing for just one of
|
||||
// them, as this may be confusing.
|
||||
if (isQuirks || stylePos->mBoxSizing == StyleBoxSizing::Content) {
|
||||
boxSizingToBorderEdge = offsets.hPadding + offsets.hBorder;
|
||||
boxSizingToBorderEdge = offsets.padding + offsets.border;
|
||||
} else {
|
||||
// StyleBoxSizing::Border and standards-mode
|
||||
minCoord += offsets.hPadding + offsets.hBorder;
|
||||
prefCoord += offsets.hPadding + offsets.hBorder;
|
||||
minCoord += offsets.padding + offsets.border;
|
||||
prefCoord += offsets.padding + offsets.border;
|
||||
}
|
||||
} else {
|
||||
minCoord = 0;
|
||||
|
|
|
@ -252,9 +252,9 @@ void FixedTableLayoutStrategy::ComputeColumnISizes(
|
|||
colISize = NSToCoordFloor(pct * float(tableISize));
|
||||
|
||||
if (cellStylePos->mBoxSizing == StyleBoxSizing::Content) {
|
||||
nsIFrame::IntrinsicISizeOffsetData offsets =
|
||||
nsIFrame::IntrinsicSizeOffsetData offsets =
|
||||
cellFrame->IntrinsicISizeOffsets();
|
||||
colISize += offsets.hPadding + offsets.hBorder;
|
||||
colISize += offsets.padding + offsets.border;
|
||||
}
|
||||
|
||||
pct /= float(colSpan);
|
||||
|
|
|
@ -742,15 +742,15 @@ nscoord nsTableCellFrame::GetPrefISize(gfxContext* aRenderingContext) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* virtual */ nsIFrame::IntrinsicISizeOffsetData
|
||||
/* virtual */ nsIFrame::IntrinsicSizeOffsetData
|
||||
nsTableCellFrame::IntrinsicISizeOffsets(nscoord aPercentageBasis) {
|
||||
IntrinsicISizeOffsetData result =
|
||||
IntrinsicSizeOffsetData result =
|
||||
nsContainerFrame::IntrinsicISizeOffsets(aPercentageBasis);
|
||||
|
||||
result.hMargin = 0;
|
||||
result.margin = 0;
|
||||
|
||||
WritingMode wm = GetWritingMode();
|
||||
result.hBorder = GetBorderWidth(wm).IStartEnd(wm);
|
||||
result.border = GetBorderWidth(wm).IStartEnd(wm);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ class nsTableCellFrame : public nsContainerFrame,
|
|||
|
||||
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
||||
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
||||
IntrinsicISizeOffsetData IntrinsicISizeOffsets(
|
||||
IntrinsicSizeOffsetData IntrinsicISizeOffsets(
|
||||
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE) override;
|
||||
|
||||
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
||||
|
|
|
@ -1486,19 +1486,19 @@ nscoord nsTableFrame::GetPrefISize(gfxContext* aRenderingContext) {
|
|||
return LayoutStrategy()->GetPrefISize(aRenderingContext, false);
|
||||
}
|
||||
|
||||
/* virtual */ nsIFrame::IntrinsicISizeOffsetData
|
||||
/* virtual */ nsIFrame::IntrinsicSizeOffsetData
|
||||
nsTableFrame::IntrinsicISizeOffsets(nscoord aPercentageBasis) {
|
||||
IntrinsicISizeOffsetData result =
|
||||
IntrinsicSizeOffsetData result =
|
||||
nsContainerFrame::IntrinsicISizeOffsets(aPercentageBasis);
|
||||
|
||||
result.hMargin = 0;
|
||||
result.margin = 0;
|
||||
|
||||
if (IsBorderCollapse()) {
|
||||
result.hPadding = 0;
|
||||
result.padding = 0;
|
||||
|
||||
WritingMode wm = GetWritingMode();
|
||||
LogicalMargin outerBC = GetIncludedOuterBCBorder(wm);
|
||||
result.hBorder = outerBC.IStartEnd(wm);
|
||||
result.border = outerBC.IStartEnd(wm);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -300,7 +300,7 @@ class nsTableFrame : public nsContainerFrame {
|
|||
// border to the results of these functions.
|
||||
virtual nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
||||
virtual nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
||||
IntrinsicISizeOffsetData IntrinsicISizeOffsets(
|
||||
IntrinsicSizeOffsetData IntrinsicISizeOffsets(
|
||||
nscoord aPercentageBasis = NS_UNCONSTRAINEDSIZE) override;
|
||||
|
||||
virtual mozilla::LogicalSize ComputeSize(
|
||||
|
|
Загрузка…
Ссылка в новой задаче