/**
 * Pushes all of the tokens in aDeque onto the front of our deque so they
 * get processed before any other tokens.
 *
 * @param aDeque The deque with the tokens in it.
 */
void
nsHTMLTokenizer::PrependTokens(nsDeque& aDeque)
{
  int32_t aCount = aDeque.GetSize();
  
  for (int32_t anIndex = 0; anIndex < aCount; ++anIndex) {
    CToken* theToken = (CToken*)aDeque.Pop();
    PushTokenFront(theToken);
  }
}
/**
 * This is a utilty method for ScanDocStructure, which finds a given
 * tag in the stack. The return value is meant to be used with
 * nsDeque::ObjectAt() on aTagStack.
 *
 * @param   aTag -- the ID of the tag we're seeking
 * @param   aTagStack -- the stack to be searched
 * @return  index position of tag in stack if found, otherwise kNotFound
 */
static int32_t
FindLastIndexOfTag(eHTMLTags aTag, nsDeque &aTagStack)
{
  int32_t theCount = aTagStack.GetSize();
  
  while (0 < theCount) {
    CHTMLToken* theToken = (CHTMLToken*)aTagStack.ObjectAt(--theCount);  
    if (theToken) {
      eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID();
      if (theTag == aTag) {
        return theCount;
      }
    }
  }

  return kNotFound;
}
示例#3
0
static bool VerifyContents(const nsDeque& aDeque, const int* aContents, int aLength) {
  for (int i=0; i<aLength; ++i) {
    if (*(int*)aDeque.ObjectAt(i) != aContents[i]) {
      return false;
    }
  }
  return true;
}
示例#4
0
void CheckIfQueueEmpty(nsDeque& d)
{
  EXPECT_EQ(0u, d.GetSize())         << "Size should be 0";
  EXPECT_EQ(nullptr, d.Pop())       <<  "Invalid operation should return nullptr";
  EXPECT_EQ(nullptr, d.PopFront())  <<  "Invalid operation should return nullptr";
  EXPECT_EQ(nullptr, d.Peek())      <<  "Invalid operation should return nullptr";
  EXPECT_EQ(nullptr, d.PeekFront()) <<  "Invalid operation should return nullptr";
  EXPECT_EQ(nullptr, d.ObjectAt(0u)) <<  "Invalid operation should return nullptr";
}
示例#5
0
 void PopAll(F&& aF) {
   while (mDQ.GetSize() != 0) {
     int i = static_cast<int>(reinterpret_cast<uintptr_t>(mDQ.Pop()));
     aF(i);
   }
 }
示例#6
0
 bool Push(int i) {
   mDQ.PushFront(reinterpret_cast<void*>(static_cast<uintptr_t>(i)));
   return true;
 }