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/. */
6 #include "mozilla/widget/nsAutoRollup.h"
12 uint32_t nsAutoRollup::sCount
= 0;
14 StaticRefPtr
<nsIContent
> nsAutoRollup::sLastRollup
;
16 nsAutoRollup::nsAutoRollup() {
17 // remember if sLastRollup was null, and only clear it upon destruction
18 // if so. This prevents recursive usage of nsAutoRollup from clearing
19 // sLastRollup when it shouldn't.
20 mWasClear
= !sLastRollup
;
24 nsAutoRollup::nsAutoRollup(nsIContent
* aRollup
) {
25 MOZ_ASSERT(!sLastRollup
);
28 SetLastRollup(aRollup
);
31 nsAutoRollup::~nsAutoRollup() {
32 if (sLastRollup
&& mWasClear
) {
33 sLastRollup
= nullptr;
39 void nsAutoRollup::SetLastRollup(nsIContent
* aLastRollup
) {
40 // There must be at least one nsAutoRollup on the stack.
43 sLastRollup
= aLastRollup
;
47 nsIContent
* nsAutoRollup::GetLastRollup() { return sLastRollup
.get(); }
50 } // namespace mozilla