2012-05-29 08:52:43 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-09-21 06:18:20 -07:00
|
|
|
|
|
|
|
#include "nsHtml5TreeOpStage.h"
|
|
|
|
|
|
|
|
nsHtml5TreeOpStage::nsHtml5TreeOpStage()
|
|
|
|
: mMutex("nsHtml5TreeOpStage mutex")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHtml5TreeOpStage::~nsHtml5TreeOpStage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-11-17 00:52:30 -08:00
|
|
|
nsHtml5TreeOpStage::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue)
|
2009-09-21 06:18:20 -07:00
|
|
|
{
|
|
|
|
mozilla::MutexAutoLock autoLock(mMutex);
|
|
|
|
if (mOpQueue.IsEmpty()) {
|
|
|
|
mOpQueue.SwapElements(aOpQueue);
|
2010-02-26 01:18:38 -08:00
|
|
|
} else {
|
|
|
|
mOpQueue.MoveElementsFrom(aOpQueue);
|
2009-09-21 06:18:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-02-26 01:18:38 -08:00
|
|
|
nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray<nsHtml5TreeOperation>& aOpQueue,
|
|
|
|
nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
|
2009-09-21 06:18:20 -07:00
|
|
|
{
|
|
|
|
mozilla::MutexAutoLock autoLock(mMutex);
|
|
|
|
if (aOpQueue.IsEmpty()) {
|
|
|
|
mOpQueue.SwapElements(aOpQueue);
|
2010-02-26 01:18:38 -08:00
|
|
|
} else {
|
|
|
|
aOpQueue.MoveElementsFrom(mOpQueue);
|
|
|
|
}
|
|
|
|
if (aSpeculativeLoadQueue.IsEmpty()) {
|
|
|
|
mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
|
|
|
|
} else {
|
|
|
|
aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
|
|
|
|
{
|
|
|
|
mozilla::MutexAutoLock autoLock(mMutex);
|
|
|
|
if (mSpeculativeLoadQueue.IsEmpty()) {
|
|
|
|
mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
|
|
|
|
} else {
|
|
|
|
mSpeculativeLoadQueue.MoveElementsFrom(aSpeculativeLoadQueue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHtml5TreeOpStage::MoveSpeculativeLoadsTo(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
|
|
|
|
{
|
|
|
|
mozilla::MutexAutoLock autoLock(mMutex);
|
|
|
|
if (aSpeculativeLoadQueue.IsEmpty()) {
|
|
|
|
mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
|
|
|
|
} else {
|
|
|
|
aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue);
|
2009-09-21 06:18:20 -07:00
|
|
|
}
|
|
|
|
}
|
2009-10-12 06:08:04 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsHtml5TreeOpStage::AssertEmpty()
|
|
|
|
{
|
|
|
|
mozilla::MutexAutoLock autoLock(mMutex);
|
|
|
|
// This shouldn't really need the mutex
|
|
|
|
NS_ASSERTION(mOpQueue.IsEmpty(), "The stage was supposed to be empty.");
|
|
|
|
}
|
|
|
|
#endif
|