1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/parser/html/nsHtml5TreeOpStage.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsHtml5TreeOpStage.h" 1.9 + 1.10 +nsHtml5TreeOpStage::nsHtml5TreeOpStage() 1.11 + : mMutex("nsHtml5TreeOpStage mutex") 1.12 +{ 1.13 +} 1.14 + 1.15 +nsHtml5TreeOpStage::~nsHtml5TreeOpStage() 1.16 +{ 1.17 +} 1.18 + 1.19 +void 1.20 +nsHtml5TreeOpStage::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue) 1.21 +{ 1.22 + mozilla::MutexAutoLock autoLock(mMutex); 1.23 + if (mOpQueue.IsEmpty()) { 1.24 + mOpQueue.SwapElements(aOpQueue); 1.25 + } else { 1.26 + mOpQueue.MoveElementsFrom(aOpQueue); 1.27 + } 1.28 +} 1.29 + 1.30 +void 1.31 +nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray<nsHtml5TreeOperation>& aOpQueue, 1.32 + nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) 1.33 +{ 1.34 + mozilla::MutexAutoLock autoLock(mMutex); 1.35 + if (aOpQueue.IsEmpty()) { 1.36 + mOpQueue.SwapElements(aOpQueue); 1.37 + } else { 1.38 + aOpQueue.MoveElementsFrom(mOpQueue); 1.39 + } 1.40 + if (aSpeculativeLoadQueue.IsEmpty()) { 1.41 + mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); 1.42 + } else { 1.43 + aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue); 1.44 + } 1.45 +} 1.46 + 1.47 +void 1.48 +nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) 1.49 +{ 1.50 + mozilla::MutexAutoLock autoLock(mMutex); 1.51 + if (mSpeculativeLoadQueue.IsEmpty()) { 1.52 + mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); 1.53 + } else { 1.54 + mSpeculativeLoadQueue.MoveElementsFrom(aSpeculativeLoadQueue); 1.55 + } 1.56 +} 1.57 + 1.58 +void 1.59 +nsHtml5TreeOpStage::MoveSpeculativeLoadsTo(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) 1.60 +{ 1.61 + mozilla::MutexAutoLock autoLock(mMutex); 1.62 + if (aSpeculativeLoadQueue.IsEmpty()) { 1.63 + mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); 1.64 + } else { 1.65 + aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue); 1.66 + } 1.67 +} 1.68 + 1.69 +#ifdef DEBUG 1.70 +void 1.71 +nsHtml5TreeOpStage::AssertEmpty() 1.72 +{ 1.73 + mozilla::MutexAutoLock autoLock(mMutex); 1.74 + // This shouldn't really need the mutex 1.75 + NS_ASSERTION(mOpQueue.IsEmpty(), "The stage was supposed to be empty."); 1.76 +} 1.77 +#endif