Skip to content

Commit

Permalink
Bug 1854424 - Add a LogicalMargin method returning an offset to start…
Browse files Browse the repository at this point in the history
…-sides. r=layout-reviewers,jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D188847
  • Loading branch information
aethanyc committed Sep 22, 2023
1 parent b1c916c commit 0319ff2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
5 changes: 2 additions & 3 deletions layout/forms/nsDateTimeControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ void nsDateTimeControlFrame::Reflow(nsPresContext* aPresContext,
LogicalMargin childMargin = childReflowInput.ComputedLogicalMargin(myWM);

// offsets of input area frame within this frame:
LogicalPoint childOffset(
myWM, borderPadding.IStart(myWM) + childMargin.IStart(myWM),
borderPadding.BStart(myWM) + childMargin.BStart(myWM));
LogicalPoint childOffset =
borderPadding.StartOffset(myWM) + childMargin.StartOffset(myWM);

nsReflowStatus childStatus;
// We initially reflow the child with a dummy containerSize; positioning
Expand Down
9 changes: 9 additions & 0 deletions layout/generic/WritingModes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,15 @@ class LogicalMargin {
return LogicalSize(aWritingMode, IStartEnd(), BStartEnd());
}

/**
* Return a LogicalPoint representing an offset to the start-sides, i.e.
* inline-start and block-start.
*/
LogicalPoint StartOffset(WritingMode aWritingMode) const {
CHECK_WRITING_MODE(aWritingMode);
return LogicalPoint(aWritingMode, IStart(), BStart());
}

/**
* Accessors for physical margins, using our writing mode to convert from
* logical values.
Expand Down
9 changes: 4 additions & 5 deletions layout/generic/nsAbsoluteContainingBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,10 @@ void nsAbsoluteContainingBlock::ReflowAbsoluteFrame(
}

LogicalRect rect(outerWM,
border.IStart(outerWM) + offsets.IStart(outerWM) +
margin.IStart(outerWM),
border.BStart(outerWM) + offsets.BStart(outerWM) +
margin.BStart(outerWM),
kidSize.ISize(outerWM), kidSize.BSize(outerWM));
border.StartOffset(outerWM) +
offsets.StartOffset(outerWM) +
margin.StartOffset(outerWM),
kidSize);
nsRect r = rect.GetPhysicalRect(
outerWM, logicalCBSize.GetPhysicalSize(wm) +
border.Size(outerWM).GetPhysicalSize(outerWM));
Expand Down
4 changes: 2 additions & 2 deletions layout/generic/nsFlexContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5400,8 +5400,8 @@ std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
// flex container's content box (with respect to its border-box), so that
// we can compute our flex item's final positions.
WritingMode flexWM = aReflowInput.GetWritingMode();
const LogicalPoint containerContentBoxOrigin(
flexWM, aBorderPadding.IStart(flexWM), aBorderPadding.BStart(flexWM));
const LogicalPoint containerContentBoxOrigin =
aBorderPadding.StartOffset(flexWM);

// The block-end of children is relative to the flex container's border-box.
nscoord maxBlockEndEdgeOfChildren = containerContentBoxOrigin.B(flexWM);
Expand Down

0 comments on commit 0319ff2

Please sign in to comment.