aNode->mView->GetZIndex(explicitZIndex);
explicitZIndex = aNode->mView->GetZIndex();
static void SortByZOrder(DisplayZTreeNode *aNode, nsVoidArray &aBuffer, nsVoidArray &aMergeTmp, PRBool aForceSort) {  PRBool autoZIndex = PR_TRUE;  PRInt32 explicitZIndex = 0;  if (nsnull != aNode->mView) {    aNode->mView->GetAutoZIndex(autoZIndex);    if (!autoZIndex) {      aNode->mView->GetZIndex(explicitZIndex);    }  }  if (nsnull == aNode->mZChild) {    if (nsnull != aNode->mDisplayElement) {      aBuffer.AppendElement(aNode->mDisplayElement);      aNode->mDisplayElement->mZIndex = explicitZIndex;      aNode->mDisplayElement = nsnull;    }    return;  }  DisplayZTreeNode *child;  PRInt32 childStartIndex = aBuffer.Count();  for (child = aNode->mZChild; nsnull != child; child = child->mZSibling) {    SortByZOrder(child, aBuffer, aMergeTmp, PR_FALSE);  }  PRInt32 childEndIndex = aBuffer.Count();  PRBool hasClip = PR_FALSE;    if (childEndIndex - childStartIndex >= 2) {    DisplayListElement2* firstChild = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(childStartIndex));    if (0 != (firstChild->mFlags & PUSH_CLIP) && firstChild->mView == aNode->mView) {      hasClip = PR_TRUE;    }  }  if (hasClip) {    ApplyZOrderStableSort(aBuffer, aMergeTmp, childStartIndex + 1, childEndIndex - 1);        if (autoZIndex && childEndIndex - childStartIndex >= 3) {      // If we're an auto-z-index, then we have to worry about the possibility that some of      // our children may be moved by the z-sorter beyond the bounds of the PUSH...POP clip      // instructions. So basically, we ensure that around every group of children of      // equal z-index, there is a PUSH...POP element pair with the same z-index. The stable      // z-sorter will not break up such a group.      // Note that if we're not an auto-z-index set, then our children will never be broken      // up so we don't need to do this.      // We also don't have to worry if we have no real children.      DisplayListElement2* ePush = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(childStartIndex));      DisplayListElement2* eFirstChild = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(childStartIndex + 1));      ePush->mZIndex = eFirstChild->mZIndex;      DisplayListElement2* ePop = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(childEndIndex - 1));      DisplayListElement2* eLastChild = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(childEndIndex - 2));      ePop->mZIndex = eLastChild->mZIndex;      DisplayListElement2* e = eFirstChild;      for (PRInt32 i = childStartIndex + 1; i < childEndIndex - 2; i++) {        DisplayListElement2* eNext = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(i + 1));        NS_ASSERTION(e->mZIndex <= eNext->mZIndex, "Display Z-list is not sorted!!");        if (e->mZIndex != eNext->mZIndex) {          // need to insert a POP for the last sequence and a PUSH for the next sequence          DisplayListElement2* newPop = new DisplayListElement2;          DisplayListElement2* newPush = new DisplayListElement2;          *newPop = *ePop;          newPop->mZIndex = e->mZIndex;          *newPush = *ePush;          newPush->mZIndex = eNext->mZIndex;          aBuffer.InsertElementAt(newPop, i + 1);          aBuffer.InsertElementAt(newPush, i + 2);          i += 2;          childEndIndex += 2;        }        e = eNext;      }    }  } else if (aForceSort || !autoZIndex) {    ApplyZOrderStableSort(aBuffer, aMergeTmp, childStartIndex, childEndIndex);  }  if (!autoZIndex) {    for (PRInt32 i = childStartIndex; i < childEndIndex; i++) {      DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(i));      element->mZIndex = explicitZIndex;    }  }}