1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 static_assert(false, "This should not be compiled in !DEBUG");
10 #include "nsAutoLayoutPhase.h"
11 #include "nsPresContext.h"
12 #include "nsContentUtils.h"
14 nsAutoLayoutPhase::nsAutoLayoutPhase(nsPresContext
* aPresContext
,
16 : mPresContext(aPresContext
)
23 nsAutoLayoutPhase::~nsAutoLayoutPhase()
26 MOZ_ASSERT(mCount
== 0, "imbalanced");
30 nsAutoLayoutPhase::Enter()
33 case eLayoutPhase_Paint
:
34 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_Paint
] == 0,
35 "recurring into paint");
36 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_Reflow
] == 0,
37 "painting in the middle of reflow");
38 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_FrameC
] == 0,
39 "painting in the middle of frame construction");
41 case eLayoutPhase_Reflow
:
42 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_Paint
] == 0,
43 "reflowing in the middle of a paint");
44 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_Reflow
] == 0,
45 "recurring into reflow");
46 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_FrameC
] == 0,
47 "reflowing in the middle of frame construction");
49 case eLayoutPhase_FrameC
:
50 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_Paint
] == 0,
51 "constructing frames in the middle of a paint");
52 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_Reflow
] == 0,
53 "constructing frames in the middle of reflow");
54 MOZ_ASSERT(mPresContext
->mLayoutPhaseCount
[eLayoutPhase_FrameC
] == 0,
55 "recurring into frame construction");
56 MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(),
57 "constructing frames and scripts are not blocked");
59 case eLayoutPhase_COUNT
:
63 ++(mPresContext
->mLayoutPhaseCount
[mPhase
]);
68 nsAutoLayoutPhase::Exit()
70 MOZ_ASSERT(mCount
> 0 && mPresContext
->mLayoutPhaseCount
[mPhase
] > 0,
72 --(mPresContext
->mLayoutPhaseCount
[mPhase
]);