Bug 1675128 Part 4 - Remove ReflowInput::ComputedPhysicalOffsets() that returns a writable-reference. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D96128
This commit is contained in:
Ting-Yu Lin 2020-11-07 00:03:38 +00:00
Родитель 1fb3ba8f3e
Коммит 43e060b82e
3 изменённых файлов: 17 добавлений и 18 удалений

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

@ -859,26 +859,26 @@ static bool RecomputePosition(nsIFrame* aFrame) {
// match the reflow code path.
//
// TODO(emilio): It'd be nice if this did logical math instead, but it seems
// to me the math should work out on vertical writing modes as well.
if (NS_AUTOOFFSET == reflowInput.ComputedPhysicalOffsets().left) {
reflowInput.ComputedPhysicalOffsets().left =
cbSize.width - reflowInput.ComputedPhysicalOffsets().right -
reflowInput.ComputedPhysicalMargin().right - size.width -
reflowInput.ComputedPhysicalMargin().left;
// to me the math should work out on vertical writing modes as well. See Bug
// 1675861 for some hints.
const nsMargin offset = reflowInput.ComputedPhysicalOffsets();
const nsMargin margin = reflowInput.ComputedPhysicalMargin();
nscoord left = offset.left;
if (left == NS_AUTOOFFSET) {
left =
cbSize.width - offset.right - margin.right - size.width - margin.left;
}
if (NS_AUTOOFFSET == reflowInput.ComputedPhysicalOffsets().top) {
reflowInput.ComputedPhysicalOffsets().top =
cbSize.height - reflowInput.ComputedPhysicalOffsets().bottom -
reflowInput.ComputedPhysicalMargin().bottom - size.height -
reflowInput.ComputedPhysicalMargin().top;
nscoord top = offset.top;
if (top == NS_AUTOOFFSET) {
top = cbSize.height - offset.bottom - margin.bottom - size.height -
margin.top;
}
// Move the frame
nsPoint pos(parentBorder.left + reflowInput.ComputedPhysicalOffsets().left +
reflowInput.ComputedPhysicalMargin().left,
parentBorder.top + reflowInput.ComputedPhysicalOffsets().top +
reflowInput.ComputedPhysicalMargin().top);
nsPoint pos(parentBorder.left + left + margin.left,
parentBorder.top + top + margin.top);
aFrame->SetPosition(pos);
if (aFrame->IsInScrollAnchorChain()) {

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

@ -2093,7 +2093,7 @@ void ReflowInput::InitConstraints(
// Override mComputedMargin since reflow roots start from the
// frame's boundary, which is inside the margin.
SetComputedLogicalMargin(wm, LogicalMargin(wm));
ComputedPhysicalOffsets().SizeTo(0, 0, 0, 0);
SetComputedLogicalOffsets(wm, LogicalMargin(wm));
const auto borderPadding = ComputedLogicalBorderPadding(wm);
ComputedISize() = AvailableISize() - borderPadding.IStartEnd(wm);
@ -2206,7 +2206,7 @@ void ReflowInput::InitConstraints(
SetComputedLogicalOffsets(cbwm, offsets);
} else {
// Initialize offsets to 0
ComputedPhysicalOffsets().SizeTo(0, 0, 0, 0);
SetComputedLogicalOffsets(wm, LogicalMargin(wm));
}
// Calculate the computed values for min and max properties. Note that

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

@ -421,7 +421,6 @@ struct ReflowInput : public SizeComputationInput {
// XXX this will need to change when we make mComputedOffsets logical;
// we won't be able to return a reference for the physical offsets
const nsMargin& ComputedPhysicalOffsets() const { return mComputedOffsets; }
nsMargin& ComputedPhysicalOffsets() { return mComputedOffsets; }
LogicalMargin ComputedLogicalOffsets(mozilla::WritingMode aWM) const {
return LogicalMargin(aWM, mComputedOffsets);