mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1877850 Part 1 - Convert callers of ReflowInput physical size accessors to use logical ones. r=dholbert
ReflowInput's computed sizes and border&padding are stored in logical coordinates, so accessing the physical version is slower [1]. This patch converts as many callers as possible to use logical coordinates. This patch doesn't change behavior. [1] For example, accessing `ComputedWidth()` and `ComputedHeight()` needs two `IsVertical()` check, but `GetPhysicalSize()` only needs one. Differential Revision: https://phabricator.services.mozilla.com/D200237
This commit is contained in:
parent
4cb7be67fe
commit
5432f83374
@ -399,7 +399,7 @@ struct ReflowInput : public SizeComputationInput {
|
||||
}
|
||||
|
||||
nsSize ComputedPhysicalSize() const {
|
||||
return nsSize(ComputedWidth(), ComputedHeight());
|
||||
return mComputedSize.GetPhysicalSize(mWritingMode);
|
||||
}
|
||||
|
||||
nsMargin ComputedPhysicalOffsets() const {
|
||||
|
@ -342,7 +342,7 @@ void ViewportFrame::Reflow(nsPresContext* aPresContext,
|
||||
// Set our size up front, since some parts of reflow depend on it
|
||||
// being already set. Note that the computed height may be
|
||||
// unconstrained; that's ok. Consumers should watch out for that.
|
||||
SetSize(nsSize(aReflowInput.ComputedWidth(), aReflowInput.ComputedHeight()));
|
||||
SetSize(aReflowInput.ComputedPhysicalSize());
|
||||
|
||||
// Reflow the main content first so that the placeholders of the
|
||||
// fixed-position frames will be in the right places on an initial
|
||||
|
@ -682,7 +682,7 @@ void nsCanvasFrame::Reflow(nsPresContext* aPresContext,
|
||||
// Set our size up front, since some parts of reflow depend on it
|
||||
// being already set. Note that the computed height may be
|
||||
// unconstrained; that's ok. Consumers should watch out for that.
|
||||
SetSize(nsSize(aReflowInput.ComputedWidth(), aReflowInput.ComputedHeight()));
|
||||
SetSize(aReflowInput.ComputedPhysicalSize());
|
||||
|
||||
// Reflow our children. Typically, we only have one child - the root
|
||||
// element's frame or a placeholder for that frame, if the root element
|
||||
|
@ -1540,15 +1540,10 @@ void nsImageFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
|
||||
RemoveStateBits(IMAGE_SIZECONSTRAINED);
|
||||
}
|
||||
|
||||
mComputedSize =
|
||||
nsSize(aReflowInput.ComputedWidth(), aReflowInput.ComputedHeight());
|
||||
mComputedSize = aReflowInput.ComputedPhysicalSize();
|
||||
|
||||
aMetrics.Width() = mComputedSize.width;
|
||||
aMetrics.Height() = mComputedSize.height;
|
||||
|
||||
// add borders and padding
|
||||
aMetrics.Width() += aReflowInput.ComputedPhysicalBorderPadding().LeftRight();
|
||||
aMetrics.Height() += aReflowInput.ComputedPhysicalBorderPadding().TopBottom();
|
||||
const auto wm = GetWritingMode();
|
||||
aMetrics.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm));
|
||||
|
||||
if (GetPrevInFlow()) {
|
||||
aMetrics.Width() = GetPrevInFlow()->GetSize().width;
|
||||
|
@ -51,8 +51,7 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
|
||||
// Set our size up front, since some parts of reflow depend on it
|
||||
// being already set. Note that the computed height may be
|
||||
// unconstrained; that's ok. Consumers should watch out for that.
|
||||
const nsSize maxSize(aReflowInput.ComputedWidth(),
|
||||
aReflowInput.ComputedHeight());
|
||||
const nsSize maxSize = aReflowInput.ComputedPhysicalSize();
|
||||
SetSize(maxSize);
|
||||
|
||||
// Writing mode for the page content frame.
|
||||
|
@ -684,11 +684,11 @@ void nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
|
||||
("enter nsSubDocumentFrame::Reflow: maxSize=%d,%d",
|
||||
aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
|
||||
|
||||
NS_ASSERTION(aReflowInput.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
|
||||
"Shouldn't have unconstrained stuff here "
|
||||
NS_ASSERTION(aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE,
|
||||
"Shouldn't have unconstrained inline-size here "
|
||||
"thanks to the rules of reflow");
|
||||
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aReflowInput.ComputedHeight(),
|
||||
"Shouldn't have unconstrained stuff here "
|
||||
NS_ASSERTION(aReflowInput.ComputedBSize() != NS_UNCONSTRAINEDSIZE,
|
||||
"Shouldn't have unconstrained block-size here "
|
||||
"thanks to ComputeAutoSize");
|
||||
|
||||
NS_ASSERTION(mContent->GetPrimaryFrame() == this, "Shouldn't happen");
|
||||
|
@ -120,8 +120,7 @@ void SVGForeignObjectFrame::Reflow(nsPresContext* aPresContext,
|
||||
|
||||
NS_ASSERTION(!aReflowInput.mParentReflowInput,
|
||||
"should only get reflow from being reflow root");
|
||||
NS_ASSERTION(aReflowInput.ComputedWidth() == GetSize().width &&
|
||||
aReflowInput.ComputedHeight() == GetSize().height,
|
||||
NS_ASSERTION(aReflowInput.ComputedSize() == GetLogicalSize(),
|
||||
"reflow roots should be reflowed at existing size and "
|
||||
"svg.css should ensure we have no padding/border/margin");
|
||||
|
||||
|
@ -334,12 +334,8 @@ void SVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
|
||||
|
||||
MOZ_ASSERT(HasAnyStateBits(NS_FRAME_IN_REFLOW), "frame is not in reflow");
|
||||
|
||||
aDesiredSize.Width() =
|
||||
aReflowInput.ComputedWidth() +
|
||||
aReflowInput.ComputedPhysicalBorderPadding().LeftRight();
|
||||
aDesiredSize.Height() =
|
||||
aReflowInput.ComputedHeight() +
|
||||
aReflowInput.ComputedPhysicalBorderPadding().TopBottom();
|
||||
const auto wm = GetWritingMode();
|
||||
aDesiredSize.SetSize(wm, aReflowInput.ComputedSizeWithBorderPadding(wm));
|
||||
|
||||
NS_ASSERTION(!GetPrevInFlow(), "SVG can't currently be broken across pages.");
|
||||
|
||||
|
@ -542,9 +542,10 @@ void nsSliderFrame::Reflow(nsPresContext* aPresContext,
|
||||
NS_ASSERTION(aReflowInput.AvailableHeight() != NS_UNCONSTRAINEDSIZE,
|
||||
"Bogus avail height");
|
||||
|
||||
const auto wm = GetWritingMode();
|
||||
|
||||
// We always take all the space we're given.
|
||||
aDesiredSize.Width() = aReflowInput.ComputedWidth();
|
||||
aDesiredSize.Height() = aReflowInput.ComputedHeight();
|
||||
aDesiredSize.SetSize(wm, aReflowInput.ComputedSize(wm));
|
||||
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
||||
|
||||
// Get the thumb, should be our only child.
|
||||
@ -556,7 +557,6 @@ void nsSliderFrame::Reflow(nsPresContext* aPresContext,
|
||||
nsScrollbarFrame* scrollbarBox = Scrollbar();
|
||||
nsIContent* scrollbar = scrollbarBox->GetContent();
|
||||
const bool horizontal = scrollbarBox->IsHorizontal();
|
||||
const auto wm = GetWritingMode();
|
||||
nsSize availSize = aDesiredSize.PhysicalSize();
|
||||
ReflowInput thumbRI(aPresContext, aReflowInput, thumbBox,
|
||||
aReflowInput.AvailableSize(wm));
|
||||
|
Loading…
Reference in New Issue
Block a user