layout/base/nsAutoLayoutPhase.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/nsAutoLayoutPhase.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef nsAutoLayoutPhase_h
     1.9 +#define nsAutoLayoutPhase_h
    1.10 +
    1.11 +#ifdef DEBUG
    1.12 +
    1.13 +// We can't forward declare an enum before C++11 which means we have to include
    1.14 +// nsPresContext.h just because nsLayoutPhase is passed to the ctor.
    1.15 +#include "nsPresContext.h"
    1.16 +
    1.17 +struct nsAutoLayoutPhase {
    1.18 +  nsAutoLayoutPhase(nsPresContext* aPresContext, nsLayoutPhase aPhase);
    1.19 +  ~nsAutoLayoutPhase();
    1.20 +
    1.21 +  void Enter();
    1.22 +  void Exit();
    1.23 +
    1.24 +private:
    1.25 +  nsPresContext* mPresContext;
    1.26 +  nsLayoutPhase mPhase;
    1.27 +  uint32_t mCount;
    1.28 +};
    1.29 +
    1.30 +#define AUTO_LAYOUT_PHASE_ENTRY_POINT(pc_, phase_) \
    1.31 +  nsAutoLayoutPhase autoLayoutPhase((pc_), (eLayoutPhase_##phase_))
    1.32 +#define LAYOUT_PHASE_TEMP_EXIT() \
    1.33 +  PR_BEGIN_MACRO \
    1.34 +    autoLayoutPhase.Exit(); \
    1.35 +  PR_END_MACRO
    1.36 +#define LAYOUT_PHASE_TEMP_REENTER() \
    1.37 +  PR_BEGIN_MACRO \
    1.38 +    autoLayoutPhase.Enter(); \
    1.39 +  PR_END_MACRO
    1.40 +
    1.41 +#else // DEBUG
    1.42 +
    1.43 +#define AUTO_LAYOUT_PHASE_ENTRY_POINT(pc_, phase_) \
    1.44 +  PR_BEGIN_MACRO PR_END_MACRO
    1.45 +#define LAYOUT_PHASE_TEMP_EXIT() \
    1.46 +  PR_BEGIN_MACRO PR_END_MACRO
    1.47 +#define LAYOUT_PHASE_TEMP_REENTER() \
    1.48 +  PR_BEGIN_MACRO PR_END_MACRO
    1.49 +
    1.50 +#endif // DEBUG
    1.51 +
    1.52 +#endif // nsAutoLayoutPhase_h

mercurial