Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef DEBUG |
michael@0 | 7 | static_assert(false, "This should not be compiled in !DEBUG"); |
michael@0 | 8 | #endif // DEBUG |
michael@0 | 9 | |
michael@0 | 10 | #include "nsAutoLayoutPhase.h" |
michael@0 | 11 | #include "nsPresContext.h" |
michael@0 | 12 | #include "nsContentUtils.h" |
michael@0 | 13 | |
michael@0 | 14 | nsAutoLayoutPhase::nsAutoLayoutPhase(nsPresContext* aPresContext, |
michael@0 | 15 | nsLayoutPhase aPhase) |
michael@0 | 16 | : mPresContext(aPresContext) |
michael@0 | 17 | , mPhase(aPhase) |
michael@0 | 18 | , mCount(0) |
michael@0 | 19 | { |
michael@0 | 20 | Enter(); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | nsAutoLayoutPhase::~nsAutoLayoutPhase() |
michael@0 | 24 | { |
michael@0 | 25 | Exit(); |
michael@0 | 26 | MOZ_ASSERT(mCount == 0, "imbalanced"); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | void |
michael@0 | 30 | nsAutoLayoutPhase::Enter() |
michael@0 | 31 | { |
michael@0 | 32 | switch (mPhase) { |
michael@0 | 33 | case eLayoutPhase_Paint: |
michael@0 | 34 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_Paint] == 0, |
michael@0 | 35 | "recurring into paint"); |
michael@0 | 36 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_Reflow] == 0, |
michael@0 | 37 | "painting in the middle of reflow"); |
michael@0 | 38 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_FrameC] == 0, |
michael@0 | 39 | "painting in the middle of frame construction"); |
michael@0 | 40 | break; |
michael@0 | 41 | case eLayoutPhase_Reflow: |
michael@0 | 42 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_Paint] == 0, |
michael@0 | 43 | "reflowing in the middle of a paint"); |
michael@0 | 44 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_Reflow] == 0, |
michael@0 | 45 | "recurring into reflow"); |
michael@0 | 46 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_FrameC] == 0, |
michael@0 | 47 | "reflowing in the middle of frame construction"); |
michael@0 | 48 | break; |
michael@0 | 49 | case eLayoutPhase_FrameC: |
michael@0 | 50 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_Paint] == 0, |
michael@0 | 51 | "constructing frames in the middle of a paint"); |
michael@0 | 52 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_Reflow] == 0, |
michael@0 | 53 | "constructing frames in the middle of reflow"); |
michael@0 | 54 | MOZ_ASSERT(mPresContext->mLayoutPhaseCount[eLayoutPhase_FrameC] == 0, |
michael@0 | 55 | "recurring into frame construction"); |
michael@0 | 56 | MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(), |
michael@0 | 57 | "constructing frames and scripts are not blocked"); |
michael@0 | 58 | break; |
michael@0 | 59 | case eLayoutPhase_COUNT: |
michael@0 | 60 | break; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | ++(mPresContext->mLayoutPhaseCount[mPhase]); |
michael@0 | 64 | ++mCount; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | void |
michael@0 | 68 | nsAutoLayoutPhase::Exit() |
michael@0 | 69 | { |
michael@0 | 70 | MOZ_ASSERT(mCount > 0 && mPresContext->mLayoutPhaseCount[mPhase] > 0, |
michael@0 | 71 | "imbalanced"); |
michael@0 | 72 | --(mPresContext->mLayoutPhaseCount[mPhase]); |
michael@0 | 73 | --mCount; |
michael@0 | 74 | } |