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/. */
5 #include "nsHtml5TreeOpStage.h"
7 nsHtml5TreeOpStage::nsHtml5TreeOpStage()
8 : mMutex("nsHtml5TreeOpStage mutex")
12 nsHtml5TreeOpStage::~nsHtml5TreeOpStage()
17 nsHtml5TreeOpStage::MoveOpsFrom(nsTArray
<nsHtml5TreeOperation
>& aOpQueue
)
19 mozilla::MutexAutoLock
autoLock(mMutex
);
20 if (mOpQueue
.IsEmpty()) {
21 mOpQueue
.SwapElements(aOpQueue
);
23 mOpQueue
.MoveElementsFrom(aOpQueue
);
28 nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray
<nsHtml5TreeOperation
>& aOpQueue
,
29 nsTArray
<nsHtml5SpeculativeLoad
>& aSpeculativeLoadQueue
)
31 mozilla::MutexAutoLock
autoLock(mMutex
);
32 if (aOpQueue
.IsEmpty()) {
33 mOpQueue
.SwapElements(aOpQueue
);
35 aOpQueue
.MoveElementsFrom(mOpQueue
);
37 if (aSpeculativeLoadQueue
.IsEmpty()) {
38 mSpeculativeLoadQueue
.SwapElements(aSpeculativeLoadQueue
);
40 aSpeculativeLoadQueue
.MoveElementsFrom(mSpeculativeLoadQueue
);
45 nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom(nsTArray
<nsHtml5SpeculativeLoad
>& aSpeculativeLoadQueue
)
47 mozilla::MutexAutoLock
autoLock(mMutex
);
48 if (mSpeculativeLoadQueue
.IsEmpty()) {
49 mSpeculativeLoadQueue
.SwapElements(aSpeculativeLoadQueue
);
51 mSpeculativeLoadQueue
.MoveElementsFrom(aSpeculativeLoadQueue
);
56 nsHtml5TreeOpStage::MoveSpeculativeLoadsTo(nsTArray
<nsHtml5SpeculativeLoad
>& aSpeculativeLoadQueue
)
58 mozilla::MutexAutoLock
autoLock(mMutex
);
59 if (aSpeculativeLoadQueue
.IsEmpty()) {
60 mSpeculativeLoadQueue
.SwapElements(aSpeculativeLoadQueue
);
62 aSpeculativeLoadQueue
.MoveElementsFrom(mSpeculativeLoadQueue
);
68 nsHtml5TreeOpStage::AssertEmpty()
70 mozilla::MutexAutoLock
autoLock(mMutex
);
71 // This shouldn't really need the mutex
72 NS_ASSERTION(mOpQueue
.IsEmpty(), "The stage was supposed to be empty.");