Bug 1307728 - use LineReflowStatusToString to support debugging.
This is a pre-patch that uses LineReflowStatusToString() function instead of
LineReflowStatusNames array to support debugging. With this patch, we could
easily regain debugging support from LineReflowStatusToString() while converting
LineReflowStatus to an enum class.
MozReview-Commit-ID: K2AzZ2zI69p
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -223,16 +223,34 @@ nsBlockFrame::InitDebugFlags()
#ifdef DEBUG
const char* nsBlockFrame::kReflowCommandType[] = {
"ContentChanged",
"StyleChanged",
"ReflowDirty",
"Timeout",
"UserDefined",
};
+
+const char*
+nsBlockFrame::LineReflowStatusToString(uint8_t aLineReflowStatus) const
+{
+ switch (aLineReflowStatus) {
+ case LINE_REFLOW_OK: return "LINE_REFLOW_OK";
+ case LINE_REFLOW_STOP: return "LINE_REFLOW_STOP";
+ case LINE_REFLOW_REDO_NO_PULL: return "LINE_REFLOW_REDO_NO_PULL";
+ case LINE_REFLOW_REDO_MORE_FLOATS: return "LINE_REFLOW_REDO_MORE_FLOATS";
+ case LINE_REFLOW_REDO_NEXT_BAND: return "LINE_REFLOW_REDO_NEXT_BAND";
+ case LINE_REFLOW_TRUNCATED: return "LINE_REFLOW_TRUNCATED";
+ default:
+ break;
+ }
+ MOZ_ASSERT_UNREACHABLE("Unknown LineReflowStatus!!");
+ return "unknown";
+}
+
#endif
#ifdef REFLOW_STATUS_COVERAGE
static void
RecordReflowStatus(bool aChildIsBlock, nsReflowStatus aFrameReflowStatus)
{
static uint32_t record[2];
@@ -3795,24 +3813,16 @@ nsBlockFrame::PushTruncatedLine(BlockRef
line_iterator aLine,
bool* aKeepReflowGoing)
{
PushLines(aState, aLine.prev());
*aKeepReflowGoing = false;
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
}
-#ifdef DEBUG
-static const char* LineReflowStatusNames[] = {
- "LINE_REFLOW_OK", "LINE_REFLOW_STOP", "LINE_REFLOW_REDO_NO_PULL",
- "LINE_REFLOW_REDO_MORE_FLOATS",
- "LINE_REFLOW_REDO_NEXT_BAND", "LINE_REFLOW_TRUNCATED"
-};
-#endif
-
void
nsBlockFrame::DoReflowInlineFrames(BlockReflowInput& aState,
nsLineLayout& aLineLayout,
line_iterator aLine,
nsFlowAreaRect& aFloatAvailableSpace,
nscoord& aAvailableSpaceHeight,
nsFloatManager::SavedState*
aFloatStateBeforeLine,
@@ -4023,17 +4033,17 @@ nsBlockFrame::DoReflowInlineFrames(Block
aKeepReflowGoing)) {
lineReflowStatus = LINE_REFLOW_REDO_MORE_FLOATS;
// PlaceLine already called GetAvailableSpaceForBSize for us.
}
}
}
#ifdef DEBUG
if (gNoisyReflow) {
- printf("Line reflow status = %s\n", LineReflowStatusNames[lineReflowStatus]);
+ printf("Line reflow status = %s\n", LineReflowStatusToString(lineReflowStatus));
}
#endif
if (aLineLayout.GetDirtyNextLine()) {
// aLine may have been pushed to the overflow lines.
FrameLines* overflowLines = GetOverflowLines();
// We can't just compare iterators front() to aLine here, since they may be in
// different lists.
--- a/layout/generic/nsBlockFrame.h
+++ b/layout/generic/nsBlockFrame.h
@@ -141,16 +141,17 @@ public:
#ifdef DEBUG_FRAME_DUMP
void List(FILE* out = stderr, const char* aPrefix = "", uint32_t aFlags = 0) const override;
virtual nsresult GetFrameName(nsAString& aResult) const override;
#endif
#ifdef DEBUG
virtual nsFrameState GetDebugStateBits() const override;
+ const char* LineReflowStatusToString(uint8_t aLineReflowStatus) const;
#endif
#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() override;
#endif
// line cursor methods to speed up searching for the line(s)
// containing a point. The basic idea is that we set the cursor