tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 310a2828942440d9ee3456966230b2da1a8d1d10
parent a08fe7ba212e959f5056c0eb13c510a3a8ebf60c
Author: Ting-Yu Lin <tlin@mozilla.com>
Date:   Wed, 19 Nov 2025 05:08:18 +0000

Bug 2000488 - Remove AxisPolarityFlipped() in ReflowInput.cpp. r=layout-reviewers,jfkthame

`AxisPolarityFlipped()` returns the negation of
`WritingMode::ParallelAxisStartsOnSameSide()`. It is sufficient to keep one
implementation in `WritingMode` and port the shortcut in
`ParallelAxisStartsOnSameSide()`.

Differential Revision: https://phabricator.services.mozilla.com/D272826

Diffstat:
Mlayout/generic/ReflowInput.cpp | 33++++-----------------------------
Mlayout/generic/WritingModes.h | 5+++++
2 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp @@ -1327,33 +1327,6 @@ static bool AreAllEarlierInFlowFramesEmpty(nsIFrame* aFrame, return true; } -static bool AxisPolarityFlipped(LogicalAxis aThisAxis, WritingMode aThisWm, - WritingMode aOtherWm) { - if (MOZ_LIKELY(aThisWm == aOtherWm)) { - // Dedicated short circuit for the common case. - return false; - } - LogicalAxis otherAxis = aThisWm.IsOrthogonalTo(aOtherWm) - ? GetOrthogonalAxis(aThisAxis) - : aThisAxis; - NS_ASSERTION( - aThisWm.PhysicalAxis(aThisAxis) == aOtherWm.PhysicalAxis(otherAxis), - "Physical axes must match!"); - Side thisStartSide = - aThisWm.PhysicalSide(MakeLogicalSide(aThisAxis, LogicalEdge::Start)); - Side otherStartSide = - aOtherWm.PhysicalSide(MakeLogicalSide(otherAxis, LogicalEdge::Start)); - return thisStartSide != otherStartSide; -} - -static bool InlinePolarityFlipped(WritingMode aThisWm, WritingMode aOtherWm) { - return AxisPolarityFlipped(LogicalAxis::Inline, aThisWm, aOtherWm); -} - -static bool BlockPolarityFlipped(WritingMode aThisWm, WritingMode aOtherWm) { - return AxisPolarityFlipped(LogicalAxis::Block, aThisWm, aOtherWm); -} - // In the code below, |aCBReflowInput->mFrame| is the absolute containing block, // while |blockContainer| is the nearest block container of the placeholder // frame, which may be different from the absolute containing block. @@ -1592,13 +1565,15 @@ void ReflowInput::CalculateHypotheticalPosition( // padding edge and our current values are relative to the border edge, so // translate. const LogicalMargin border = aCBReflowInput->ComputedLogicalBorder(wm); - if (hypotheticalPosWillUseCbwm && InlinePolarityFlipped(wm, cbwm)) { + if (hypotheticalPosWillUseCbwm && + !wm.ParallelAxisStartsOnSameSide(LogicalAxis::Inline, cbwm)) { aHypotheticalPos.mIStart += border.IEnd(wm); } else { aHypotheticalPos.mIStart -= border.IStart(wm); } - if (hypotheticalPosWillUseCbwm && BlockPolarityFlipped(wm, cbwm)) { + if (hypotheticalPosWillUseCbwm && + !wm.ParallelAxisStartsOnSameSide(LogicalAxis::Block, cbwm)) { aHypotheticalPos.mBStart += border.BEnd(wm); } else { aHypotheticalPos.mBStart -= border.BStart(wm); diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h @@ -532,6 +532,11 @@ class WritingMode { */ bool ParallelAxisStartsOnSameSide(LogicalAxis aLogicalAxis, const WritingMode& aOther) const { + if (MOZ_LIKELY(*this == aOther)) { + // Dedicated short circuit for the common case. + return true; + } + mozilla::Side myStartSide = this->PhysicalSide(MakeLogicalSide(aLogicalAxis, LogicalEdge::Start));