1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef nsAutoLayoutPhase_h 6 #define nsAutoLayoutPhase_h 7 8 #ifdef DEBUG 9 10 // We can't forward declare an enum before C++11 which means we have to include 11 // nsPresContext.h just because nsLayoutPhase is passed to the ctor. 12 #include "nsPresContext.h" 13 14 struct nsAutoLayoutPhase { 15 nsAutoLayoutPhase(nsPresContext* aPresContext, nsLayoutPhase aPhase); 16 ~nsAutoLayoutPhase(); 17 18 void Enter(); 19 void Exit(); 20 21 private: 22 nsPresContext* mPresContext; 23 nsLayoutPhase mPhase; 24 uint32_t mCount; 25 }; 26 27 #define AUTO_LAYOUT_PHASE_ENTRY_POINT(pc_, phase_) \ 28 nsAutoLayoutPhase autoLayoutPhase((pc_), (eLayoutPhase_##phase_)) 29 #define LAYOUT_PHASE_TEMP_EXIT() \ 30 PR_BEGIN_MACRO \ 31 autoLayoutPhase.Exit(); \ 32 PR_END_MACRO 33 #define LAYOUT_PHASE_TEMP_REENTER() \ 34 PR_BEGIN_MACRO \ 35 autoLayoutPhase.Enter(); \ 36 PR_END_MACRO 37 38 #else // DEBUG 39 40 #define AUTO_LAYOUT_PHASE_ENTRY_POINT(pc_, phase_) \ 41 PR_BEGIN_MACRO PR_END_MACRO 42 #define LAYOUT_PHASE_TEMP_EXIT() \ 43 PR_BEGIN_MACRO PR_END_MACRO 44 #define LAYOUT_PHASE_TEMP_REENTER() \ 45 PR_BEGIN_MACRO PR_END_MACRO 46 47 #endif // DEBUG 48 49 #endif // nsAutoLayoutPhase_h 50