summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--layout/generic/nsFlexContainerFrame.cpp39
-rw-r--r--layout/generic/nsFlexContainerFrame.h15
-rw-r--r--layout/generic/nsFrame.cpp11
3 files changed, 7 insertions, 58 deletions
diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp
index b4907a4862..02d15b5907 100644
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1990,10 +1990,6 @@ FlexItem::FlexItem(ReflowInput& aFlexItemReflowInput,
"placeholder frames should not be treated as flex items");
MOZ_ASSERT(!(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW),
"out-of-flow frames should not be treated as flex items");
- MOZ_ASSERT(mIsInlineAxisMainAxis ==
- nsFlexContainerFrame::IsItemInlineAxisMainAxis(mFrame),
- "public API should be consistent with internal state (about "
- "whether flex item's inline axis is flex container's main axis)");
const ReflowInput* containerRS = aFlexItemReflowInput.mParentReflowInput;
if (IsLegacyBox(containerRS->mFrame)) {
@@ -4425,41 +4421,6 @@ nsFlexContainerFrame::CalculatePackingSpace(uint32_t aNumThingsToPack,
*aPackingSpaceRemaining -= totalEdgePackingSpace;
}
-/* static */
-bool
-nsFlexContainerFrame::IsItemInlineAxisMainAxis(nsIFrame* aFrame)
-{
- MOZ_ASSERT(aFrame && aFrame->IsFlexItem(), "expecting arg to be a flex item");
- const WritingMode flexItemWM = aFrame->GetWritingMode();
- const nsIFrame* flexContainer = aFrame->GetParent();
-
- if (IsLegacyBox(flexContainer)) {
- // For legacy boxes, the main axis is determined by "box-orient", and we can
- // just directly check if that's vertical, and compare that to whether the
- // item's WM is also vertical:
- bool boxOrientIsVertical =
- (flexContainer->StyleXUL()->mBoxOrient == StyleBoxOrient::Vertical);
- return flexItemWM.IsVertical() == boxOrientIsVertical;
- }
-
- // For modern CSS flexbox, we get our return value by asking two questions
- // and comparing their answers.
- // Question 1: does aFrame have the same inline axis as its flex container?
- bool itemInlineAxisIsParallelToParent =
- !flexItemWM.IsOrthogonalTo(flexContainer->GetWritingMode());
-
- // Question 2: is aFrame's flex container row-oriented? (This tells us
- // whether the flex container's main axis is its inline axis.)
- auto flexDirection = flexContainer->StylePosition()->mFlexDirection;
- bool flexContainerIsRowOriented =
- flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
- flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
-
- // aFrame's inline axis is its flex container's main axis IFF the above
- // questions have the same answer.
- return flexContainerIsRowOriented == itemInlineAxisIsParallelToParent;
-}
-
void
nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h
index e349709876..42ccdfeb85 100644
--- a/layout/generic/nsFlexContainerFrame.h
+++ b/layout/generic/nsFlexContainerFrame.h
@@ -133,21 +133,6 @@ public:
uint32_t* aNumPackingSpacesRemaining,
nscoord* aPackingSpaceRemaining);
- /**
- * Given a frame for a flex item, this method returns true IFF that flex
- * item's inline axis is the same as (i.e. not orthogonal to) its flex
- * container's main axis.
- *
- * (This method is only intended to be used from external
- * callers. Inside of flex reflow code, FlexItem::IsInlineAxisMainAxis() is
- * equivalent & more optimal.)
- *
- * @param aFrame a flex item (must return true from IsFlexItem)
- * @return true iff aFrame's inline axis is the same as (i.e. not orthogonal
- * to) its flex container's main axis. Otherwise, false.
- */
- static bool IsItemInlineAxisMainAxis(nsIFrame* aFrame);
-
protected:
// Protected constructor & destructor
explicit nsFlexContainerFrame(nsStyleContext* aContext)
diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
index 9bc4941e0b..43ad970890 100644
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -39,7 +39,6 @@
#include "mozilla/Logging.h"
#include "mozilla/Sprintf.h"
#include "nsFrameManager.h"
-#include "nsFlexContainerFrame.h"
#include "nsLayoutUtils.h"
#include "LayoutLogging.h"
#include "mozilla/RestyleManager.h"
@@ -4753,11 +4752,12 @@ nsFrame::ComputeSize(nsRenderingContext* aRenderingContext,
}
bool isFlexItem = (parentFrameType == nsGkAtoms::flexContainerFrame &&
!(GetStateBits() & NS_FRAME_OUT_OF_FLOW));
-
bool isInlineFlexItem = false;
if (isFlexItem) {
+ uint32_t flexDirection = GetParent()->StylePosition()->mFlexDirection;
isInlineFlexItem =
- nsFlexContainerFrame::IsItemInlineAxisMainAxis(this);
+ flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
+ flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
const nsStyleCoord* flexBasis = &(stylePos->mFlexBasis);
SetCoordToFlexBasis(isInlineFlexItem, false, flexBasis,
@@ -4973,8 +4973,11 @@ nsFrame::ComputeSizeWithIntrinsicDimensions(nsRenderingContext* aRenderingConte
// from our style struct. (Otherwise, we'll be using an irrelevant value in
// the aspect-ratio calculations below.)
if (isFlexItem) {
+ uint32_t flexDirection =
+ GetParent()->StylePosition()->mFlexDirection;
isInlineFlexItem =
- nsFlexContainerFrame::IsItemInlineAxisMainAxis(this);
+ flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
+ flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
// If FlexItemMainSizeOverride frame-property is set, then that means the
// flex container is imposing a main-size on this flex item for it to use