nsHtml5TreeOpStage.cpp (1883B)
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/. */ 4 5 #include "nsHtml5TreeOpStage.h" 6 7 using namespace mozilla; 8 9 nsHtml5TreeOpStage::nsHtml5TreeOpStage() : mMutex("nsHtml5TreeOpStage mutex") {} 10 11 nsHtml5TreeOpStage::~nsHtml5TreeOpStage() {} 12 13 bool nsHtml5TreeOpStage::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue) { 14 mozilla::MutexAutoLock autoLock(mMutex); 15 return !!mOpQueue.AppendElements(std::move(aOpQueue), mozilla::fallible_t()); 16 } 17 18 [[nodiscard]] bool nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo( 19 nsTArray<nsHtml5TreeOperation>& aOpQueue, 20 nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) { 21 mozilla::MutexAutoLock autoLock(mMutex); 22 if (!aOpQueue.AppendElements(std::move(mOpQueue), mozilla::fallible_t())) { 23 return false; 24 }; 25 aSpeculativeLoadQueue.AppendElements(std::move(mSpeculativeLoadQueue)); 26 return true; 27 } 28 29 [[nodiscard]] bool nsHtml5TreeOpStage::MoveOpsTo( 30 nsTArray<nsHtml5TreeOperation>& aOpQueue) { 31 mozilla::MutexAutoLock autoLock(mMutex); 32 return !!aOpQueue.AppendElements(std::move(mOpQueue), mozilla::fallible_t()); 33 } 34 35 void nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom( 36 nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) { 37 mozilla::MutexAutoLock autoLock(mMutex); 38 mSpeculativeLoadQueue.AppendElements(std::move(aSpeculativeLoadQueue)); 39 } 40 41 void nsHtml5TreeOpStage::MoveSpeculativeLoadsTo( 42 nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) { 43 mozilla::MutexAutoLock autoLock(mMutex); 44 aSpeculativeLoadQueue.AppendElements(std::move(mSpeculativeLoadQueue)); 45 } 46 47 #ifdef DEBUG 48 void nsHtml5TreeOpStage::AssertEmpty() { 49 mozilla::MutexAutoLock autoLock(mMutex); 50 MOZ_ASSERT(mOpQueue.IsEmpty(), "The stage was supposed to be empty."); 51 } 52 #endif