Bug 1674450 Part 7 - Store SizeComputationInput's computed margin, border/padding, and padding in logical coordinates. r=layout-reviewers,jfkthame

The one-argument SetComputedLogicalMargin(),
SetComputedLogicalBorderPadding(), and SetComputedLogicalPadding() are
not changed because the next part are going to delete them.

Note that I'm deliberately not making ComputedLogicalMargin() and others
to return `const LogicalMargin&` because the compilers can use RVO to
eliminate unnecessary copy. If we'd like to convert them to accept all
writing mode like `nsIFrame::GetLogicalUsedMargin(WritingMode)` so that
the caller don't need to call `ConvertTo`, they can't return a const
reference anyway.

Differential Revision: https://phabricator.services.mozilla.com/D95370
This commit is contained in:
Ting-Yu Lin 2020-10-31 14:42:04 +00:00
Родитель 8c17380539
Коммит 1531f4b093
3 изменённых файлов: 32 добавлений и 29 удалений

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

@ -111,7 +111,10 @@ SizeComputationInput::SizeComputationInput(nsIFrame* aFrame,
gfxContext* aRenderingContext) gfxContext* aRenderingContext)
: mFrame(aFrame), : mFrame(aFrame),
mRenderingContext(aRenderingContext), mRenderingContext(aRenderingContext),
mWritingMode(aFrame->GetWritingMode()) {} mWritingMode(aFrame->GetWritingMode()),
mComputedMargin(mWritingMode),
mComputedBorderPadding(mWritingMode),
mComputedPadding(mWritingMode) {}
SizeComputationInput::SizeComputationInput( SizeComputationInput::SizeComputationInput(
nsIFrame* aFrame, gfxContext* aRenderingContext, nsIFrame* aFrame, gfxContext* aRenderingContext,
@ -2446,7 +2449,7 @@ void SizeComputationInput::InitOffsets(WritingMode aCBWM, nscoord aPercentBasis,
side = MakeLogicalSide(aAxis, eLogicalEdgeEnd); side = MakeLogicalSide(aAxis, eLogicalEdgeEnd);
val = -val; val = -val;
} }
mComputedPadding.Side(wm.PhysicalSide(side)) += val; mComputedPadding.Side(side, wm) += val;
needPaddingProp = true; needPaddingProp = true;
if (aAxis == eLogicalAxisBlock && val > 0) { if (aAxis == eLogicalAxisBlock && val > 0) {
// We have a baseline-adjusted block-axis start padding, so // We have a baseline-adjusted block-axis start padding, so

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

@ -117,41 +117,41 @@ struct SizeComputationInput {
// Rendering context to use for measurement. // Rendering context to use for measurement.
gfxContext* mRenderingContext; gfxContext* mRenderingContext;
const nsMargin& ComputedPhysicalMargin() const { return mComputedMargin; } nsMargin ComputedPhysicalMargin() const {
const nsMargin& ComputedPhysicalBorderPadding() const { return mComputedMargin.GetPhysicalMargin(mWritingMode);
}
nsMargin ComputedPhysicalBorderPadding() const {
return mComputedBorderPadding.GetPhysicalMargin(mWritingMode);
}
nsMargin ComputedPhysicalPadding() const {
return mComputedPadding.GetPhysicalMargin(mWritingMode);
}
LogicalMargin ComputedLogicalMargin() const { return mComputedMargin; }
LogicalMargin ComputedLogicalBorderPadding() const {
return mComputedBorderPadding; return mComputedBorderPadding;
} }
const nsMargin& ComputedPhysicalPadding() const { return mComputedPadding; } LogicalMargin ComputedLogicalPadding() const { return mComputedPadding; }
LogicalMargin ComputedLogicalMargin() const {
return LogicalMargin(mWritingMode, mComputedMargin);
}
LogicalMargin ComputedLogicalBorderPadding() const {
return LogicalMargin(mWritingMode, mComputedBorderPadding);
}
LogicalMargin ComputedLogicalPadding() const {
return LogicalMargin(mWritingMode, mComputedPadding);
}
void SetComputedLogicalMargin(mozilla::WritingMode aWM, void SetComputedLogicalMargin(mozilla::WritingMode aWM,
const LogicalMargin& aMargin) { const LogicalMargin& aMargin) {
mComputedMargin = aMargin.GetPhysicalMargin(aWM); mComputedMargin = aMargin.ConvertTo(mWritingMode, aWM);
} }
void SetComputedLogicalMargin(const LogicalMargin& aMargin) { void SetComputedLogicalMargin(const LogicalMargin& aMargin) {
SetComputedLogicalMargin(mWritingMode, aMargin); SetComputedLogicalMargin(mWritingMode, aMargin);
} }
void SetComputedLogicalBorderPadding(mozilla::WritingMode aWM, void SetComputedLogicalBorderPadding(mozilla::WritingMode aWM,
const LogicalMargin& aMargin) { const LogicalMargin& aBorderPadding) {
mComputedBorderPadding = aMargin.GetPhysicalMargin(aWM); mComputedBorderPadding = aBorderPadding.ConvertTo(mWritingMode, aWM);
} }
void SetComputedLogicalBorderPadding(const LogicalMargin& aMargin) { void SetComputedLogicalBorderPadding(const LogicalMargin& aMargin) {
SetComputedLogicalBorderPadding(mWritingMode, aMargin); SetComputedLogicalBorderPadding(mWritingMode, aMargin);
} }
void SetComputedLogicalPadding(mozilla::WritingMode aWM, void SetComputedLogicalPadding(mozilla::WritingMode aWM,
const LogicalMargin& aMargin) { const LogicalMargin& aPadding) {
mComputedPadding = aMargin.GetPhysicalMargin(aWM); mComputedPadding = aPadding.ConvertTo(mWritingMode, aWM);
} }
void SetComputedLogicalPadding(const LogicalMargin& aMargin) { void SetComputedLogicalPadding(const LogicalMargin& aMargin) {
SetComputedLogicalPadding(mWritingMode, aMargin); SetComputedLogicalPadding(mWritingMode, aMargin);
@ -163,17 +163,14 @@ struct SizeComputationInput {
// cached copy of the frame's writing-mode, for logical coordinates // cached copy of the frame's writing-mode, for logical coordinates
WritingMode mWritingMode; WritingMode mWritingMode;
// These are PHYSICAL coordinates (for now).
// Will probably become logical in due course.
// Computed margin values // Computed margin values
nsMargin mComputedMargin; LogicalMargin mComputedMargin;
// Cached copy of the border + padding values // Cached copy of the border + padding values
nsMargin mComputedBorderPadding; LogicalMargin mComputedBorderPadding;
// Computed padding values // Computed padding values
nsMargin mComputedPadding; LogicalMargin mComputedPadding;
public: public:
// Callers using this constructor must call InitOffsets on their own. // Callers using this constructor must call InitOffsets on their own.

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

@ -12353,9 +12353,12 @@ void SizeComputationInput::DisplayInitOffsetsExit(nsIFrame* aFrame,
if (treeNode->mDisplay) { if (treeNode->mDisplay) {
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent); DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
printf("InitOffsets="); printf("InitOffsets=");
DR_state->PrintMargin("m", &aState->ComputedPhysicalMargin()); const auto m = aState->ComputedPhysicalMargin();
DR_state->PrintMargin("p", &aState->ComputedPhysicalPadding()); DR_state->PrintMargin("m", &m);
DR_state->PrintMargin("p+b", &aState->ComputedPhysicalBorderPadding()); const auto p = aState->ComputedPhysicalPadding();
DR_state->PrintMargin("p", &p);
const auto bp = aState->ComputedPhysicalBorderPadding();
DR_state->PrintMargin("b+p", &bp);
putchar('\n'); putchar('\n');
} }
DR_state->DeleteTreeNode(*treeNode); DR_state->DeleteTreeNode(*treeNode);