From f210ff2e08f34c989a4473e1284b92217d5b5dd8 Mon Sep 17 00:00:00 2001 From: Jeremy Chen Date: Fri, 7 Oct 2016 00:36:07 +0800 Subject: [PATCH] Bug 1307728 - use LineReflowStatusToString to support debugging. r=mats 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 --HG-- extra : rebase_source : bfbb1221ffb59cd4c27c3fb147a3a3b64e86cf68 --- layout/generic/nsBlockFrame.cpp | 28 +++++++++++++++++++--------- layout/generic/nsBlockFrame.h | 1 + 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index cdf4ae78722e..7bc23d762dfc 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -228,6 +228,24 @@ const char* nsBlockFrame::kReflowCommandType[] = { "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 @@ -3800,14 +3818,6 @@ nsBlockFrame::PushTruncatedLine(BlockReflowInput& aState, 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, @@ -4028,7 +4038,7 @@ nsBlockFrame::DoReflowInlineFrames(BlockReflowInput& aState, } #ifdef DEBUG if (gNoisyReflow) { - printf("Line reflow status = %s\n", LineReflowStatusNames[lineReflowStatus]); + printf("Line reflow status = %s\n", LineReflowStatusToString(lineReflowStatus)); } #endif diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 6f7ccb47023f..1f343a7ab02a 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -146,6 +146,7 @@ public: #ifdef DEBUG virtual nsFrameState GetDebugStateBits() const override; + const char* LineReflowStatusToString(uint8_t aLineReflowStatus) const; #endif #ifdef ACCESSIBILITY