зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1909761 Part 1 - Improve lambda expressions in nsLayoutUtils::IntrinsicForAxis(). r=dholbert
Capitalize the name of lambda expressions to make them look like functions rather than variables. Rename and improve `GetContentEdgeToBoxSizing` since I feel the indentation makes it difficult to read. Also, rename the local `Maybe<LogicalSize>` storing the result of the lambda. This patch doesn't change behavior. Differential Revision: https://phabricator.services.mozilla.com/D219520
This commit is contained in:
Родитель
22ffbfd8d5
Коммит
409ffc8b8e
|
@ -4593,7 +4593,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
aFrame->GetWritingMode().PhysicalAxis(LogicalAxis::Inline);
|
aFrame->GetWritingMode().PhysicalAxis(LogicalAxis::Inline);
|
||||||
const bool isInlineAxis = aAxis == ourInlineAxis;
|
const bool isInlineAxis = aAxis == ourInlineAxis;
|
||||||
|
|
||||||
auto resetIfKeywords = [](StyleSize& aSize, StyleSize& aMinSize,
|
auto ResetIfKeywords = [](StyleSize& aSize, StyleSize& aMinSize,
|
||||||
StyleMaxSize& aMaxSize) {
|
StyleMaxSize& aMaxSize) {
|
||||||
if (!aSize.IsLengthPercentage()) {
|
if (!aSize.IsLengthPercentage()) {
|
||||||
aSize = StyleSize::Auto();
|
aSize = StyleSize::Auto();
|
||||||
|
@ -4611,7 +4611,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
// -moz-available for intrinsic size in block axis. Therefore, we reset them
|
// -moz-available for intrinsic size in block axis. Therefore, we reset them
|
||||||
// if needed.
|
// if needed.
|
||||||
if (!isInlineAxis) {
|
if (!isInlineAxis) {
|
||||||
resetIfKeywords(styleISize, styleMinISize, styleMaxISize);
|
ResetIfKeywords(styleISize, styleMinISize, styleMaxISize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We build up two values starting with the content box, and then
|
// We build up two values starting with the content box, and then
|
||||||
|
@ -4650,26 +4650,26 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
? aPercentageBasis->BSize(childWM)
|
? aPercentageBasis->BSize(childWM)
|
||||||
: aPercentageBasis->ISize(childWM);
|
: aPercentageBasis->ISize(childWM);
|
||||||
}
|
}
|
||||||
nsIFrame::IntrinsicSizeOffsetData offsets =
|
nsIFrame::IntrinsicSizeOffsetData offsetInRequestedAxis =
|
||||||
MOZ_LIKELY(isInlineAxis)
|
MOZ_LIKELY(isInlineAxis)
|
||||||
? aFrame->IntrinsicISizeOffsets(pmPercentageBasis)
|
? aFrame->IntrinsicISizeOffsets(pmPercentageBasis)
|
||||||
: aFrame->IntrinsicBSizeOffsets(pmPercentageBasis);
|
: aFrame->IntrinsicBSizeOffsets(pmPercentageBasis);
|
||||||
|
|
||||||
auto getContentBoxSizeToBoxSizingAdjust =
|
auto GetContentEdgeToBoxSizing = [&](const StyleBoxSizing aBoxSizing) {
|
||||||
[childWM, &offsets, &aFrame, isInlineAxis,
|
if (aBoxSizing == StyleBoxSizing::Content) {
|
||||||
pmPercentageBasis](const StyleBoxSizing aBoxSizing) {
|
return LogicalSize(childWM);
|
||||||
return aBoxSizing == StyleBoxSizing::Border
|
}
|
||||||
? LogicalSize(childWM,
|
nsIFrame::IntrinsicSizeOffsetData offsetInOtherAxis =
|
||||||
(isInlineAxis ? offsets
|
MOZ_LIKELY(isInlineAxis)
|
||||||
: aFrame->IntrinsicISizeOffsets(
|
? aFrame->IntrinsicBSizeOffsets(pmPercentageBasis)
|
||||||
pmPercentageBasis))
|
: aFrame->IntrinsicISizeOffsets(pmPercentageBasis);
|
||||||
.BorderPadding(),
|
const auto& inlineOffset =
|
||||||
(!isInlineAxis ? offsets
|
isInlineAxis ? offsetInRequestedAxis : offsetInOtherAxis;
|
||||||
: aFrame->IntrinsicBSizeOffsets(
|
const auto& blockOffset =
|
||||||
pmPercentageBasis))
|
isInlineAxis ? offsetInOtherAxis : offsetInRequestedAxis;
|
||||||
.BorderPadding())
|
return LogicalSize(childWM, inlineOffset.BorderPadding(),
|
||||||
: LogicalSize(childWM);
|
blockOffset.BorderPadding());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper to compute the block-size, max-block-size, and min-block-size later
|
// Helper to compute the block-size, max-block-size, and min-block-size later
|
||||||
// in this function.
|
// in this function.
|
||||||
|
@ -4685,7 +4685,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
};
|
};
|
||||||
|
|
||||||
Maybe<nscoord> iSizeFromAspectRatio;
|
Maybe<nscoord> iSizeFromAspectRatio;
|
||||||
Maybe<LogicalSize> contentBoxSizeToBoxSizingAdjust;
|
Maybe<LogicalSize> contentEdgeToBoxSizing;
|
||||||
|
|
||||||
const bool ignorePadding =
|
const bool ignorePadding =
|
||||||
(aFlags & IGNORE_PADDING) || aFrame->IsAbsolutelyPositioned();
|
(aFlags & IGNORE_PADDING) || aFrame->IsAbsolutelyPositioned();
|
||||||
|
@ -4766,7 +4766,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
// -moz-available for intrinsic size in block axis. Therefore, we reset them
|
// -moz-available for intrinsic size in block axis. Therefore, we reset them
|
||||||
// if needed.
|
// if needed.
|
||||||
if (isInlineAxis) {
|
if (isInlineAxis) {
|
||||||
resetIfKeywords(styleBSize, styleMinBSize, styleMaxBSize);
|
ResetIfKeywords(styleBSize, styleMinBSize, styleMaxBSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If our BSize or min/max-BSize properties are set to values that we can
|
// If our BSize or min/max-BSize properties are set to values that we can
|
||||||
|
@ -4804,8 +4804,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
|
|
||||||
nscoord bSizeTakenByBoxSizing = GetDefiniteSizeTakenByBoxSizing(
|
nscoord bSizeTakenByBoxSizing = GetDefiniteSizeTakenByBoxSizing(
|
||||||
boxSizing, aFrame, !isInlineAxis, ignorePadding, aPercentageBasis);
|
boxSizing, aFrame, !isInlineAxis, ignorePadding, aPercentageBasis);
|
||||||
contentBoxSizeToBoxSizingAdjust.emplace(
|
contentEdgeToBoxSizing.emplace(GetContentEdgeToBoxSizing(boxSizing));
|
||||||
getContentBoxSizeToBoxSizingAdjust(boxSizing));
|
|
||||||
// NOTE: This is only the minContentSize if we've been passed
|
// NOTE: This is only the minContentSize if we've been passed
|
||||||
// MIN_INTRINSIC_ISIZE (which is fine, because this should only be used
|
// MIN_INTRINSIC_ISIZE (which is fine, because this should only be used
|
||||||
// inside a check for that flag).
|
// inside a check for that flag).
|
||||||
|
@ -4816,7 +4815,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
// dimensions of |aFrame|.
|
// dimensions of |aFrame|.
|
||||||
result = ratio.ComputeRatioDependentSize(
|
result = ratio.ComputeRatioDependentSize(
|
||||||
isInlineAxis ? LogicalAxis::Inline : LogicalAxis::Block, childWM,
|
isInlineAxis ? LogicalAxis::Inline : LogicalAxis::Block, childWM,
|
||||||
*bSize, *contentBoxSizeToBoxSizingAdjust);
|
*bSize, *contentEdgeToBoxSizing);
|
||||||
// We have got the iSizeForAspectRatio value, so we don't need to
|
// We have got the iSizeForAspectRatio value, so we don't need to
|
||||||
// compute this again below.
|
// compute this again below.
|
||||||
iSizeFromAspectRatio.emplace(result);
|
iSizeFromAspectRatio.emplace(result);
|
||||||
|
@ -4826,7 +4825,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
*maxBSize = std::max(0, *maxBSize - bSizeTakenByBoxSizing);
|
*maxBSize = std::max(0, *maxBSize - bSizeTakenByBoxSizing);
|
||||||
nscoord maxISize = ratio.ComputeRatioDependentSize(
|
nscoord maxISize = ratio.ComputeRatioDependentSize(
|
||||||
isInlineAxis ? LogicalAxis::Inline : LogicalAxis::Block, childWM,
|
isInlineAxis ? LogicalAxis::Inline : LogicalAxis::Block, childWM,
|
||||||
*maxBSize, *contentBoxSizeToBoxSizingAdjust);
|
*maxBSize, *contentEdgeToBoxSizing);
|
||||||
if (maxISize < result) {
|
if (maxISize < result) {
|
||||||
result = maxISize;
|
result = maxISize;
|
||||||
}
|
}
|
||||||
|
@ -4839,7 +4838,7 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
*minBSize = std::max(0, *minBSize - bSizeTakenByBoxSizing);
|
*minBSize = std::max(0, *minBSize - bSizeTakenByBoxSizing);
|
||||||
nscoord minISize = ratio.ComputeRatioDependentSize(
|
nscoord minISize = ratio.ComputeRatioDependentSize(
|
||||||
isInlineAxis ? LogicalAxis::Inline : LogicalAxis::Block, childWM,
|
isInlineAxis ? LogicalAxis::Inline : LogicalAxis::Block, childWM,
|
||||||
*minBSize, *contentBoxSizeToBoxSizingAdjust);
|
*minBSize, *contentEdgeToBoxSizing);
|
||||||
if (minISize > result) {
|
if (minISize > result) {
|
||||||
result = minISize;
|
result = minISize;
|
||||||
}
|
}
|
||||||
|
@ -4887,25 +4886,25 @@ nscoord nsLayoutUtils::IntrinsicForAxis(
|
||||||
// We cannot reuse |boxSizing| because it may be updated to content-box
|
// We cannot reuse |boxSizing| because it may be updated to content-box
|
||||||
// in the above if-branch.
|
// in the above if-branch.
|
||||||
const StyleBoxSizing boxSizingForAR = stylePos->mBoxSizing;
|
const StyleBoxSizing boxSizingForAR = stylePos->mBoxSizing;
|
||||||
if (!contentBoxSizeToBoxSizingAdjust) {
|
if (!contentEdgeToBoxSizing) {
|
||||||
contentBoxSizeToBoxSizingAdjust.emplace(
|
contentEdgeToBoxSizing.emplace(
|
||||||
getContentBoxSizeToBoxSizingAdjust(boxSizingForAR));
|
GetContentEdgeToBoxSizing(boxSizingForAR));
|
||||||
}
|
}
|
||||||
nscoord bSizeTakenByBoxSizing =
|
nscoord bSizeTakenByBoxSizing =
|
||||||
GetDefiniteSizeTakenByBoxSizing(boxSizingForAR, aFrame, !isInlineAxis,
|
GetDefiniteSizeTakenByBoxSizing(boxSizingForAR, aFrame, !isInlineAxis,
|
||||||
ignorePadding, aPercentageBasis);
|
ignorePadding, aPercentageBasis);
|
||||||
|
|
||||||
*bSize -= bSizeTakenByBoxSizing;
|
*bSize -= bSizeTakenByBoxSizing;
|
||||||
iSizeFromAspectRatio.emplace(
|
iSizeFromAspectRatio.emplace(ar.ComputeRatioDependentSize(
|
||||||
ar.ComputeRatioDependentSize(LogicalAxis::Inline, childWM, *bSize,
|
LogicalAxis::Inline, childWM, *bSize, *contentEdgeToBoxSizing));
|
||||||
*contentBoxSizeToBoxSizingAdjust));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord contentBoxSize = result;
|
nscoord contentBoxSize = result;
|
||||||
result = AddIntrinsicSizeOffset(
|
result = AddIntrinsicSizeOffset(
|
||||||
aRenderingContext, aFrame, offsets, aType, boxSizing, result, min,
|
aRenderingContext, aFrame, offsetInRequestedAxis, aType, boxSizing,
|
||||||
styleISize, fixedMinISize, styleMinISize, fixedMaxISize, styleMaxISize,
|
result, min, styleISize, fixedMinISize, styleMinISize, fixedMaxISize,
|
||||||
iSizeFromAspectRatio, aFlags, aAxis);
|
styleMaxISize, iSizeFromAspectRatio, aFlags, aAxis);
|
||||||
nscoord overflow = result - aMarginBoxMinSizeClamp;
|
nscoord overflow = result - aMarginBoxMinSizeClamp;
|
||||||
if (MOZ_UNLIKELY(overflow > 0)) {
|
if (MOZ_UNLIKELY(overflow > 0)) {
|
||||||
nscoord newContentBoxSize = std::max(nscoord(0), contentBoxSize - overflow);
|
nscoord newContentBoxSize = std::max(nscoord(0), contentBoxSize - overflow);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче