Bug 1631941 - Add DEBUG-only mWritingMode to mozilla::LogicalSides. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D71885
This commit is contained in:
L. David Baron 2020-04-22 17:54:28 +00:00
Родитель 6dd37deb03
Коммит 129af7be9b
12 изменённых файлов: 89 добавлений и 62 удалений

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

@ -116,44 +116,6 @@ enum LineRelativeDir {
eLineRelativeDirRight = eLogicalSideIEnd
};
/**
* LogicalSides represents a set of logical sides.
*/
struct LogicalSides final {
LogicalSides() : mBits(0) {}
explicit LogicalSides(LogicalSideBits aSideBits) {
MOZ_ASSERT((aSideBits & ~eLogicalSideBitsAll) == 0, "illegal side bits");
mBits = aSideBits;
}
bool IsEmpty() const { return mBits == 0; }
bool BStart() const { return mBits & eLogicalSideBitsBStart; }
bool BEnd() const { return mBits & eLogicalSideBitsBEnd; }
bool IStart() const { return mBits & eLogicalSideBitsIStart; }
bool IEnd() const { return mBits & eLogicalSideBitsIEnd; }
bool Contains(LogicalSideBits aSideBits) const {
MOZ_ASSERT((aSideBits & ~eLogicalSideBitsAll) == 0, "illegal side bits");
return (mBits & aSideBits) == aSideBits;
}
LogicalSides operator|(LogicalSides aOther) const {
return LogicalSides(LogicalSideBits(mBits | aOther.mBits));
}
LogicalSides operator|(LogicalSideBits aSideBits) const {
return *this | LogicalSides(aSideBits);
}
LogicalSides& operator|=(LogicalSides aOther) {
mBits |= aOther.mBits;
return *this;
}
LogicalSides& operator|=(LogicalSideBits aSideBits) {
return *this |= LogicalSides(aSideBits);
}
bool operator==(LogicalSides aOther) const { return mBits == aOther.mBits; }
bool operator!=(LogicalSides aOther) const { return !(*this == aOther); }
private:
uint8_t mBits;
};
/**
* mozilla::WritingMode is an immutable class representing a
* writing mode.
@ -616,6 +578,7 @@ class WritingMode {
private:
friend class LogicalPoint;
friend class LogicalSize;
friend class LogicalSides;
friend class LogicalMargin;
friend class LogicalRect;
@ -1109,6 +1072,65 @@ class LogicalSize {
nsSize mSize;
};
/**
* LogicalSides represents a set of logical sides.
*/
struct LogicalSides final {
explicit LogicalSides(WritingMode aWritingMode)
:
#ifdef DEBUG
mWritingMode(aWritingMode),
#endif
mBits(0) {
}
LogicalSides(WritingMode aWritingMode, LogicalSideBits aSideBits)
:
#ifdef DEBUG
mWritingMode(aWritingMode),
#endif
mBits(aSideBits) {
MOZ_ASSERT((aSideBits & ~eLogicalSideBitsAll) == 0, "illegal side bits");
}
bool IsEmpty() const { return mBits == 0; }
bool BStart() const { return mBits & eLogicalSideBitsBStart; }
bool BEnd() const { return mBits & eLogicalSideBitsBEnd; }
bool IStart() const { return mBits & eLogicalSideBitsIStart; }
bool IEnd() const { return mBits & eLogicalSideBitsIEnd; }
bool Contains(LogicalSideBits aSideBits) const {
MOZ_ASSERT((aSideBits & ~eLogicalSideBitsAll) == 0, "illegal side bits");
return (mBits & aSideBits) == aSideBits;
}
LogicalSides operator|(LogicalSides aOther) const {
// FIXME: Check writing modes here.
return *this | LogicalSideBits(aOther.mBits);
}
LogicalSides operator|(LogicalSideBits aSideBits) const {
return LogicalSides(GetWritingMode(), LogicalSideBits(mBits | aSideBits));
}
LogicalSides& operator|=(LogicalSides aOther) {
// FIXME: Check writing modes here.
return *this |= LogicalSideBits(aOther.mBits);
}
LogicalSides& operator|=(LogicalSideBits aSideBits) {
mBits |= aSideBits;
return *this;
}
bool operator==(LogicalSides aOther) const { return mBits == aOther.mBits; }
bool operator!=(LogicalSides aOther) const { return !(*this == aOther); }
#ifdef DEBUG
WritingMode GetWritingMode() const { return mWritingMode; }
#else
WritingMode GetWritingMode() const { return WritingMode::Unknown(); }
#endif
private:
#ifdef DEBUG
WritingMode mWritingMode;
#endif
uint8_t mBits;
};
/**
* Flow-relative margin
*/

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

@ -384,7 +384,7 @@ nsIFrame::LogicalSides nsFirstLetterFrame::GetLogicalSkipSides(
// properties that could trigger a call to GetSkipSides. Then again,
// it's not really an error to call GetSkipSides on any frame, so
// that's why we handle it properly.
return LogicalSides(eLogicalSideBitsAll);
return LogicalSides(mWritingMode, eLogicalSideBitsAll);
}
return LogicalSides(); // first continuation displays all sides
return LogicalSides(mWritingMode); // first continuation displays all sides
}

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

@ -2765,6 +2765,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::GridReflowInput {
mFragBStart(0),
mStartRow(0),
mNextFragmentStartRow(0),
mSkipSides(aFrame->GetWritingMode()),
mWM(aWM),
mInFragmentainer(false) {
MOZ_ASSERT(!aReflowInput || aReflowInput->mFrame == mFrame);

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

@ -3390,7 +3390,7 @@ class nsIFrame : public nsQueryFrame {
Sides GetSkipSides(const ReflowInput* aReflowInput = nullptr) const;
virtual LogicalSides GetLogicalSkipSides(
const ReflowInput* aReflowInput = nullptr) const {
return LogicalSides();
return LogicalSides(mWritingMode);
}
/**

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

@ -2419,11 +2419,11 @@ void nsImageFrame::List(FILE* out, const char* aPrefix,
nsIFrame::LogicalSides nsImageFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (nullptr != GetPrevInFlow()) {
skip |= eLogicalSideBitsBStart;
}

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

@ -794,12 +794,12 @@ void nsInlineFrame::PushFrames(nsPresContext* aPresContext,
nsIFrame::LogicalSides nsInlineFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (!IsFirst()) {
nsInlineFrame* prev = (nsInlineFrame*)GetPrevContinuation();
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
@ -831,7 +831,7 @@ nsIFrame::LogicalSides nsInlineFrame::GetLogicalSkipSides(
// a split should skip the "start" side. But figuring out which part of
// the split we are involves getting our first continuation, which might be
// expensive. So don't bother if we already have the relevant bits set.
if (skip != LogicalSides(eLogicalSideBitsIBoth)) {
if (skip != LogicalSides(mWritingMode, eLogicalSideBitsIBoth)) {
// We're missing one of the skip bits, so check whether we need to set it.
// Only get the first continuation once, as an optimization.
nsIFrame* firstContinuation = FirstContinuation();

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

@ -225,16 +225,17 @@ nscoord nsSplittableFrame::GetEffectiveComputedBSize(
nsIFrame::LogicalSides nsSplittableFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (IS_TRUE_OVERFLOW_CONTAINER(this)) {
return LogicalSides(eLogicalSideBitsBBoth);
skip |= eLogicalSideBitsBBoth;
return skip;
}
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (GetPrevContinuation()) {
skip |= eLogicalSideBitsBStart;
}
@ -270,13 +271,16 @@ nsIFrame::LogicalSides nsSplittableFrame::GetLogicalSkipSides(
}
LogicalSides nsSplittableFrame::PreReflowBlockLevelLogicalSkipSides() const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(IS_TRUE_OVERFLOW_CONTAINER(this))) {
return LogicalSides(mozilla::eLogicalSideBitsBBoth);
skip |= mozilla::eLogicalSideBitsBBoth;
return skip;
}
if (MOZ_LIKELY(StyleBorder()->mBoxDecorationBreak !=
StyleBoxDecorationBreak::Clone) &&
GetPrevInFlow()) {
return LogicalSides(mozilla::eLogicalSideBitsBStart);
skip |= mozilla::eLogicalSideBitsBStart;
return skip;
}
return LogicalSides();
return skip;
}

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

@ -524,12 +524,12 @@ void nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame::LogicalSides nsTableCellFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (nullptr != GetPrevInFlow()) {
skip |= eLogicalSideBitsBStart;
}

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

@ -299,12 +299,12 @@ void nsTableColGroupFrame::RemoveFrame(ChildListID aListID,
nsIFrame::LogicalSides nsTableColGroupFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (nullptr != GetPrevInFlow()) {
skip |= eLogicalSideBitsBStart;
}

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

@ -1342,12 +1342,12 @@ nsMargin nsTableFrame::GetDeflationForBackground(
nsIFrame::LogicalSides nsTableFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
// frame attribute was accounted for in nsHTMLTableElement::MapTableBorderInto
// account for pagination
if (nullptr != GetPrevInFlow()) {

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

@ -552,12 +552,12 @@ void nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame::LogicalSides nsTableRowFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (nullptr != GetPrevInFlow()) {
skip |= eLogicalSideBitsBStart;
}

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

@ -259,12 +259,12 @@ void nsTableRowGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame::LogicalSides nsTableRowGroupFrame::GetLogicalSkipSides(
const ReflowInput* aReflowInput) const {
LogicalSides skip(mWritingMode);
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
StyleBoxDecorationBreak::Clone)) {
return LogicalSides();
return skip;
}
LogicalSides skip;
if (nullptr != GetPrevInFlow()) {
skip |= eLogicalSideBitsBStart;
}