Bug 474369 - get rid of nsVoidArray; layout part; r+sr=roc

This commit is contained in:
Arpad Borsos 2009-02-03 15:42:18 +01:00
Родитель 0ea4dd1d2d
Коммит 6db605f5b3
42 изменённых файлов: 503 добавлений и 507 удалений

Просмотреть файл

@ -257,7 +257,7 @@ AdvanceLineIteratorToFrame(nsIFrame* aFrame,
* Overview of the implementation of Resolve():
*
* Walk through the descendants of aBlockFrame and build:
* * mLogicalArray: an nsVoidArray of nsIFrame* pointers in logical order
* * mLogicalFrames: an nsTArray of nsIFrame* pointers in logical order
* * mBuffer: an nsAutoString containing a representation of
* the content of the frames.
* In the case of text frames, this is the actual text context of the
@ -274,7 +274,7 @@ AdvanceLineIteratorToFrame(nsIFrame* aFrame,
* nsBidi::CountRuns().
*
* Finally, walk these runs in logical order using nsBidi::GetLogicalRun() and
* correlate them with the frames indexed in mLogicalArray, setting the
* correlate them with the frames indexed in mLogicalFrames, setting the
* baseLevel, embeddingLevel, and charType properties according to the results
* returned by the Bidi engine and CalculateCharType().
*
@ -361,7 +361,7 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
PRInt32 fragmentLength = 0;
PRInt32 temp;
PRInt32 frameIndex = -1;
PRInt32 frameCount = mLogicalFrames.Count();
PRInt32 frameCount = mLogicalFrames.Length();
PRInt32 contentOffset = 0; // offset within current frame
PRInt32 lineOffset = 0; // offset within mBuffer
PRInt32 logicalLimit = 0;
@ -392,7 +392,7 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
}
contentOffset = 0;
frame = (nsIFrame*) (mLogicalFrames[frameIndex]);
frame = mLogicalFrames[frameIndex];
frameType = frame->GetType();
lineNeedsUpdate = PR_TRUE;
if (nsGkAtoms::textFrame == frameType) {
@ -516,7 +516,7 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame,
return mSuccess;
}
// Should this frame be treated as a leaf (e.g. when building mLogicalArray)?
// Should this frame be treated as a leaf (e.g. when building mLogicalFrames)?
PRBool IsBidiLeaf(nsIFrame* aFrame) {
nsIFrame* kid = aFrame->GetFirstChild(nsnull);
return !kid
@ -594,7 +594,7 @@ nsBidiPresUtils::InitLogicalArray(nsIFrame* aCurrentFrame)
*/
nsIContent* content = frame->GetContent();
if (content) {
mContentToFrameIndex.Put(content, mLogicalFrames.Count());
mContentToFrameIndex.Put(content, mLogicalFrames.Length());
}
mLogicalFrames.AppendElement(frame);
}
@ -623,10 +623,10 @@ nsBidiPresUtils::CreateBlockBuffer()
nsIFrame* frame;
nsIContent* prevContent = nsnull;
PRUint32 i;
PRUint32 count = mLogicalFrames.Count();
PRUint32 count = mLogicalFrames.Length();
for (i = 0; i < count; i++) {
frame = (nsIFrame*) (mLogicalFrames[i]);
frame = mLogicalFrames[i];
nsIAtom* frameType = frame->GetType();
if (nsGkAtoms::textFrame == frameType) {
@ -686,7 +686,7 @@ nsBidiPresUtils::Reorder(PRBool& aReordered, PRBool& aHasRTLFrames)
{
aReordered = PR_FALSE;
aHasRTLFrames = PR_FALSE;
PRInt32 count = mLogicalFrames.Count();
PRInt32 count = mLogicalFrames.Length();
if (mArraySize < count) {
mArraySize = count << 1;
@ -711,7 +711,7 @@ nsBidiPresUtils::Reorder(PRBool& aReordered, PRBool& aHasRTLFrames)
PRInt32 i;
for (i = 0; i < count; i++) {
frame = (nsIFrame*) (mLogicalFrames[i]);
frame = mLogicalFrames[i];
mLevels[i] = GetFrameEmbeddingLevel(frame);
if (mLevels[i] & 1) {
aHasRTLFrames = PR_TRUE;
@ -885,15 +885,15 @@ nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame,
// If aIsOddLevel is true, so we need to traverse the child list
// in reverse order, to make it O(n) we store the list locally and
// iterate the list reversely
nsVoidArray childList;
nsTArray<nsIFrame*> childList;
nsIFrame *frame = aFrame->GetFirstChild(nsnull);
if (frame && aIsOddLevel) {
childList.AppendElement(nsnull);
childList.AppendElement((nsIFrame*)nsnull);
while (frame) {
childList.AppendElement(frame);
frame = frame->GetNextSibling();
}
frame = (nsIFrame*)childList[childList.Count() - 1];
frame = childList[childList.Length() - 1];
}
// Reposition the child frames
@ -905,7 +905,7 @@ nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame,
aContinuationStates);
index++;
frame = aIsOddLevel ?
(nsIFrame*)childList[childList.Count() - index - 1] :
childList[childList.Length() - index - 1] :
frame->GetNextSibling();
}
@ -959,7 +959,7 @@ nsBidiPresUtils::RepositionInlineFrames(nsIFrame* aFirstChild) const
nscoord left = aFirstChild->GetPosition().x - leftSpace;
nsIFrame* frame;
PRInt32 count = mVisualFrames.Count();
PRInt32 count = mVisualFrames.Length();
PRInt32 index;
nsContinuationStates continuationStates;
@ -968,13 +968,12 @@ nsBidiPresUtils::RepositionInlineFrames(nsIFrame* aFirstChild) const
// Initialize continuation states to (nsnull, 0) for
// each frame on the line.
for (index = 0; index < count; index++) {
InitContinuationStates((nsIFrame*)mVisualFrames[index],
&continuationStates);
InitContinuationStates(mVisualFrames[index], &continuationStates);
}
// Reposition frames in visual order
for (index = 0; index < count; index++) {
frame = (nsIFrame*) (mVisualFrames[index]);
frame = mVisualFrames[index];
RepositionFrame(frame,
(mLevels[mIndexMap[index]] & 1),
left,
@ -1004,13 +1003,13 @@ nsBidiPresUtils::CheckLineOrder(nsIFrame* aFirstFrameOnLine,
PRBool isReordered;
PRBool hasRTLFrames;
Reorder(isReordered, hasRTLFrames);
PRInt32 count = mLogicalFrames.Count();
PRInt32 count = mLogicalFrames.Length();
if (aFirstVisual) {
*aFirstVisual = (nsIFrame*)mVisualFrames[0];
*aFirstVisual = mVisualFrames[0];
}
if (aLastVisual) {
*aLastVisual = (nsIFrame*)mVisualFrames[count-1];
*aLastVisual = mVisualFrames[count-1];
}
// If there's an RTL frame, assume the line is reordered
@ -1027,14 +1026,14 @@ nsBidiPresUtils::GetFrameToRightOf(const nsIFrame* aFrame,
PRBool isReordered;
PRBool hasRTLFrames;
Reorder(isReordered, hasRTLFrames);
PRInt32 count = mVisualFrames.Count();
PRInt32 count = mVisualFrames.Length();
if (aFrame == nsnull)
return (nsIFrame*)mVisualFrames[0];
return mVisualFrames[0];
for (PRInt32 i = 0; i < count - 1; i++) {
if ((nsIFrame*)mVisualFrames[i] == aFrame) {
return (nsIFrame*)mVisualFrames[i+1];
if (mVisualFrames[i] == aFrame) {
return mVisualFrames[i+1];
}
}
@ -1051,14 +1050,14 @@ nsBidiPresUtils::GetFrameToLeftOf(const nsIFrame* aFrame,
PRBool isReordered;
PRBool hasRTLFrames;
Reorder(isReordered, hasRTLFrames);
PRInt32 count = mVisualFrames.Count();
PRInt32 count = mVisualFrames.Length();
if (aFrame == nsnull)
return (nsIFrame*)mVisualFrames[count-1];
return mVisualFrames[count-1];
for (PRInt32 i = 1; i < count; i++) {
if ((nsIFrame*)mVisualFrames[i] == aFrame) {
return (nsIFrame*)mVisualFrames[i-1];
if (mVisualFrames[i] == aFrame) {
return mVisualFrames[i-1];
}
}
@ -1084,8 +1083,8 @@ nsBidiPresUtils::EnsureBidiContinuation(nsIFrame* aFrame,
nsCharType charType = (nsCharType)NS_PTR_TO_INT32(aFrame->GetProperty(nsGkAtoms::charType));
// Skip fluid continuations
while (aFrameIndex + 1 < mLogicalFrames.Count()) {
nsIFrame* frame = (nsIFrame*)mLogicalFrames[aFrameIndex + 1];
while (aFrameIndex + 1 < PRInt32(mLogicalFrames.Length())) {
nsIFrame* frame = mLogicalFrames[aFrameIndex + 1];
if (frame->GetPrevInFlow() != aFrame) {
// If we found a non-fluid continuation, use it
if (frame->GetPrevContinuation() == aFrame) {
@ -1134,7 +1133,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIFrame* aFrame,
NS_ASSERTION(NS_SUCCEEDED(rv), "charType attribute missing from aFrame");
for (PRInt32 index = aFirstIndex + 1; index <= aLastIndex; index++) {
nsIFrame* frame = (nsIFrame*) mLogicalFrames[index];
nsIFrame* frame = mLogicalFrames[index];
if (nsGkAtoms::directionalFrame == frame->GetType()) {
frame->Destroy();
++aOffset;
@ -1428,7 +1427,7 @@ nsresult nsBidiPresUtils::ProcessText(const PRUnichar* aText,
nsAutoString runVisualText;
runVisualText.Assign(aText + start, subRunLength);
if (runVisualText.Length() < subRunLength)
if (PRInt32(runVisualText.Length()) < subRunLength)
return NS_ERROR_OUT_OF_MEMORY;
FormatUnicodeText(aPresContext, runVisualText.BeginWriting(), subRunLength,
(nsCharType)charType, level & 1);

Просмотреть файл

@ -42,7 +42,7 @@
#ifndef nsBidiPresUtils_h___
#define nsBidiPresUtils_h___
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIFrame.h"
#include "nsBidi.h"
#include "nsBidiUtils.h"
@ -488,8 +488,8 @@ private:
void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength) const;
nsAutoString mBuffer;
nsVoidArray mLogicalFrames;
nsVoidArray mVisualFrames;
nsTArray<nsIFrame*> mLogicalFrames;
nsTArray<nsIFrame*> mVisualFrames;
nsDataHashtable<nsISupportsHashKey, PRInt32> mContentToFrameIndex;
PRInt32 mArraySize;
PRInt32* mIndexMap;

Просмотреть файл

@ -123,6 +123,7 @@
#include "nsStyleUtil.h"
#include "nsIFocusEventSuppressor.h"
#include "nsBox.h"
#include "nsTArray.h"
#ifdef MOZ_XUL
#include "nsIRootBox.h"
@ -8197,16 +8198,16 @@ nsCSSFrameConstructor::ReinsertContent(nsIContent* aContainer,
}
static void
DoDeletingFrameSubtree(nsFrameManager* aFrameManager,
nsVoidArray& aDestroyQueue,
nsIFrame* aRemovedFrame,
nsIFrame* aFrame);
DoDeletingFrameSubtree(nsFrameManager* aFrameManager,
nsTArray<nsIFrame*>& aDestroyQueue,
nsIFrame* aRemovedFrame,
nsIFrame* aFrame);
static void
DoDeletingOverflowContainers(nsFrameManager* aFrameManager,
nsVoidArray& aDestroyQueue,
nsIFrame* aRemovedFrame,
nsIFrame* aFrame)
DoDeletingOverflowContainers(nsFrameManager* aFrameManager,
nsTArray<nsIFrame*>& aDestroyQueue,
nsIFrame* aRemovedFrame,
nsIFrame* aFrame)
{
// The invariant that "continuing frames should be found as part of the
// walk over the top-most frame's continuing frames" does not hold for
@ -8247,10 +8248,10 @@ DoDeletingOverflowContainers(nsFrameManager* aFrameManager,
* this changes
*/
static void
DoDeletingFrameSubtree(nsFrameManager* aFrameManager,
nsVoidArray& aDestroyQueue,
nsIFrame* aRemovedFrame,
nsIFrame* aFrame)
DoDeletingFrameSubtree(nsFrameManager* aFrameManager,
nsTArray<nsIFrame*>& aDestroyQueue,
nsIFrame* aRemovedFrame,
nsIFrame* aFrame)
{
#undef RECURSE
#define RECURSE(top, child) \
@ -8331,7 +8332,7 @@ DeletingFrameSubtree(nsFrameManager* aFrameManager,
return NS_OK;
}
nsAutoVoidArray destroyQueue;
nsAutoTArray<nsIFrame*, 8> destroyQueue;
// If it's a "special" block-in-inline frame, then we can't really deal.
// That really shouldn't be happening.
@ -8355,8 +8356,8 @@ DeletingFrameSubtree(nsFrameManager* aFrameManager,
// Now destroy any out-of-flow frames that have been enqueued for
// destruction.
for (PRInt32 i = destroyQueue.Count() - 1; i >= 0; --i) {
nsIFrame* outOfFlowFrame = static_cast<nsIFrame*>(destroyQueue[i]);
for (PRInt32 i = destroyQueue.Length() - 1; i >= 0; --i) {
nsIFrame* outOfFlowFrame = destroyQueue[i];
// Ask the out-of-flow's parent to delete the out-of-flow
// frame from the right list.

Просмотреть файл

@ -61,7 +61,6 @@ class nsStyleContext;
struct nsStyleContent;
struct nsStyleDisplay;
class nsIPresShell;
class nsVoidArray;
class nsFrameManager;
class nsIDOMHTMLSelectElement;
class nsPresContext;

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsCounterManager.h"
#include "nsBulletFrame.h" // legacy location for list style type to text code
#include "nsContentUtils.h"
#include "nsTArray.h"
PRBool
nsCounterUseNode::InitTextFrame(nsGenConList* aList,
@ -98,7 +99,7 @@ nsCounterUseNode::GetText(nsString& aResult)
{
aResult.Truncate();
nsAutoVoidArray stack;
nsAutoTArray<nsCounterNode*, 8> stack;
stack.AppendElement(static_cast<nsCounterNode*>(this));
if (mAllCounters && mScopeStart)
@ -110,8 +111,8 @@ nsCounterUseNode::GetText(nsString& aResult)
if (mAllCounters)
separator = mCounterStyle->Item(1).GetStringBufferValue();
for (PRInt32 i = stack.Count() - 1;; --i) {
nsCounterNode *n = static_cast<nsCounterNode*>(stack[i]);
for (PRUint32 i = stack.Length() - 1;; --i) {
nsCounterNode *n = stack[i];
nsBulletFrame::AppendCounterText(style, n->mValueAfter, aResult);
if (i == 0)
break;

Просмотреть файл

@ -79,6 +79,7 @@
#include "gfxMatrix.h"
#include "gfxTypes.h"
#include "gfxUserFontSet.h"
#include "nsTArray.h"
#ifdef MOZ_SVG
#include "nsSVGUtils.h"
@ -1586,7 +1587,7 @@ nsLayoutUtils::GetClosestCommonAncestorViaPlaceholders(nsIFrame* aFrame1,
}
nsFrameManager* frameManager = presContext->PresShell()->FrameManager();
nsAutoVoidArray frame1Ancestors;
nsAutoTArray<nsIFrame*, 8> frame1Ancestors;
nsIFrame* f1;
for (f1 = aFrame1; f1 && f1 != aKnownCommonAncestorHint;
f1 = GetParentOrPlaceholderFor(frameManager, f1)) {
@ -1598,7 +1599,7 @@ nsLayoutUtils::GetClosestCommonAncestorViaPlaceholders(nsIFrame* aFrame1,
aKnownCommonAncestorHint = nsnull;
}
nsAutoVoidArray frame2Ancestors;
nsAutoTArray<nsIFrame*, 8> frame2Ancestors;
nsIFrame* f2;
for (f2 = aFrame2; f2 && f2 != aKnownCommonAncestorHint;
f2 = GetParentOrPlaceholderFor(frameManager, f2)) {
@ -1615,10 +1616,10 @@ nsLayoutUtils::GetClosestCommonAncestorViaPlaceholders(nsIFrame* aFrame1,
// the root frame. We need to walk from the end (i.e., the top of the
// frame (sub)tree) down to aFrame1/aFrame2 looking for the first difference.
nsIFrame* lastCommonFrame = aKnownCommonAncestorHint;
PRInt32 last1 = frame1Ancestors.Count() - 1;
PRInt32 last2 = frame2Ancestors.Count() - 1;
PRInt32 last1 = frame1Ancestors.Length() - 1;
PRInt32 last2 = frame2Ancestors.Length() - 1;
while (last1 >= 0 && last2 >= 0) {
nsIFrame* frame1 = static_cast<nsIFrame*>(frame1Ancestors.ElementAt(last1));
nsIFrame* frame1 = frame1Ancestors.ElementAt(last1);
if (frame1 != frame2Ancestors.ElementAt(last2))
break;
lastCommonFrame = frame1;

Просмотреть файл

@ -76,7 +76,7 @@
#include "prmem.h"
#include "prprf.h"
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsCOMArray.h"
#include "nsHashtable.h"
#include "nsIViewObserver.h"
@ -1123,7 +1123,7 @@ protected:
PRUint32 mUpdateCount;
#endif
// reflow roots that need to be reflowed, as both a queue and a hashtable
nsVoidArray mDirtyRoots;
nsTArray<nsIFrame*> mDirtyRoots;
PRPackedBool mDocumentLoading;
PRPackedBool mIsReflowing;
@ -1133,7 +1133,7 @@ protected:
nsIFrame* mCurrentEventFrame;
nsCOMPtr<nsIContent> mCurrentEventContent;
nsVoidArray mCurrentEventFrameStack;
nsTArray<nsIFrame*> mCurrentEventFrameStack;
nsCOMArray<nsIContent> mCurrentEventContentStack;
nsCOMPtr<nsIContent> mLastAnchorScrolledTo;
@ -1664,9 +1664,9 @@ PresShell::Destroy()
mCurrentEventFrame = nsnull;
PRInt32 i, count = mCurrentEventFrameStack.Count();
PRInt32 i, count = mCurrentEventFrameStack.Length();
for (i = 0; i < count; i++) {
mCurrentEventFrameStack.ReplaceElementAt(nsnull, i);
mCurrentEventFrameStack[i] = nsnull;
}
if (mViewManager) {
@ -2440,14 +2440,14 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
if (rootFrame) {
// Note: Because the frame just got created, it has the NS_FRAME_IS_DIRTY
// bit set. Unset it so that FrameNeedsReflow() will work right.
NS_ASSERTION(mDirtyRoots.IndexOf(rootFrame) == -1,
NS_ASSERTION(!mDirtyRoots.Contains(rootFrame),
"Why is the root in mDirtyRoots already?");
rootFrame->RemoveStateBits(NS_FRAME_IS_DIRTY |
NS_FRAME_HAS_DIRTY_CHILDREN);
FrameNeedsReflow(rootFrame, eResize, NS_FRAME_IS_DIRTY);
NS_ASSERTION(mDirtyRoots.IndexOf(rootFrame) != -1,
NS_ASSERTION(mDirtyRoots.Contains(rootFrame),
"Should be in mDirtyRoots now");
NS_ASSERTION(mReflowEvent.IsPending(), "Why no reflow event pending?");
}
@ -2604,7 +2604,7 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
if (!mIgnoreFrameDestruction) {
mFrameConstructor->NotifyDestroyingFrame(aFrame);
for (PRInt32 idx = mDirtyRoots.Count(); idx; ) {
for (PRInt32 idx = mDirtyRoots.Length(); idx; ) {
--idx;
if (mDirtyRoots[idx] == aFrame) {
mDirtyRoots.RemoveElementAt(idx);
@ -3103,7 +3103,7 @@ PresShell::VerifyHasDirtyRootAncestor(nsIFrame* aFrame)
while (aFrame && (aFrame->GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN)) {
if (((aFrame->GetStateBits() & NS_FRAME_REFLOW_ROOT) ||
!aFrame->GetParent()) &&
mDirtyRoots.IndexOf(aFrame) != -1) {
mDirtyRoots.Contains(aFrame)) {
return;
}
@ -3178,15 +3178,15 @@ PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
}
if (aIntrinsicDirty == eStyleChange) {
// Mark all descendants dirty (using an nsVoidArray stack rather than
// Mark all descendants dirty (using an nsTArray stack rather than
// recursion).
nsVoidArray stack;
nsTArray<nsIFrame*> stack;
stack.AppendElement(aFrame);
while (stack.Count() != 0) {
while (stack.Length() != 0) {
nsIFrame *f =
static_cast<nsIFrame*>(stack.FastElementAt(stack.Count() - 1));
stack.RemoveElementAt(stack.Count() - 1);
stack.ElementAt(stack.Length() - 1);
stack.RemoveElementAt(stack.Length() - 1);
PRInt32 childListIndex = 0;
nsIAtom *childListName;
@ -3358,13 +3358,13 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
}
#endif
for (int i=0; i<mCurrentEventFrameStack.Count(); i++) {
if (aFrame == (nsIFrame*)mCurrentEventFrameStack.ElementAt(i)) {
for (unsigned int i=0; i < mCurrentEventFrameStack.Length(); i++) {
if (aFrame == mCurrentEventFrameStack.ElementAt(i)) {
//One of our stack frames was deleted. Get its content so that when we
//pop it we can still get its new frame from its content
nsIContent *currentEventContent = aFrame->GetContent();
mCurrentEventContentStack.ReplaceObjectAt(currentEventContent, i);
mCurrentEventFrameStack.ReplaceElementAt(nsnull, i);
mCurrentEventFrameStack[i] = nsnull;
}
}
@ -4303,7 +4303,7 @@ PresShell::UnsuppressPainting()
// the reflows and get all the frames where we want them
// before actually unlocking the painting. Otherwise
// go ahead and unlock now.
if (mDirtyRoots.Count() > 0)
if (mDirtyRoots.Length() > 0)
mShouldUnsuppressPainting = PR_TRUE;
else
UnsuppressAndInvalidate();
@ -5431,7 +5431,7 @@ void
PresShell::PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent)
{
if (mCurrentEventFrame || mCurrentEventContent) {
mCurrentEventFrameStack.InsertElementAt((void*)mCurrentEventFrame, 0);
mCurrentEventFrameStack.InsertElementAt(0, mCurrentEventFrame);
mCurrentEventContentStack.InsertObjectAt(mCurrentEventContent, 0);
}
mCurrentEventFrame = aFrame;
@ -5444,8 +5444,8 @@ PresShell::PopCurrentEventInfo()
mCurrentEventFrame = nsnull;
mCurrentEventContent = nsnull;
if (0 != mCurrentEventFrameStack.Count()) {
mCurrentEventFrame = (nsIFrame*)mCurrentEventFrameStack.ElementAt(0);
if (0 != mCurrentEventFrameStack.Length()) {
mCurrentEventFrame = mCurrentEventFrameStack.ElementAt(0);
mCurrentEventFrameStack.RemoveElementAt(0);
mCurrentEventContent = mCurrentEventContentStack.ObjectAt(0);
mCurrentEventContentStack.RemoveObjectAt(0);
@ -6503,7 +6503,7 @@ void
PresShell::PostReflowEvent()
{
if (mReflowEvent.IsPending() || mIsDestroying || mIsReflowing ||
mDirtyRoots.Count() == 0)
mDirtyRoots.Length() == 0)
return;
nsRefPtr<ReflowEvent> ev = new ReflowEvent(this);
@ -6659,7 +6659,7 @@ PresShell::DoVerifyReflow()
ok ? "ok" : "failed");
}
if (0 != mDirtyRoots.Count()) {
if (0 != mDirtyRoots.Length()) {
printf("XXX yikes! reflow commands queued during verify-reflow\n");
}
}
@ -6672,7 +6672,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
MOZ_TIMER_DEBUGLOG(("Start: Reflow: PresShell::ProcessReflowCommands(), this=%p\n", this));
MOZ_TIMER_START(mReflowWatch);
if (0 != mDirtyRoots.Count()) {
if (0 != mDirtyRoots.Length()) {
#ifdef DEBUG
if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) {
@ -6695,8 +6695,8 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
do {
// Send an incremental reflow notification to the target frame.
PRInt32 idx = mDirtyRoots.Count() - 1;
nsIFrame *target = static_cast<nsIFrame*>(mDirtyRoots[idx]);
PRInt32 idx = mDirtyRoots.Length() - 1;
nsIFrame *target = mDirtyRoots[idx];
mDirtyRoots.RemoveElementAt(idx);
if (!NS_SUBTREE_DIRTY(target)) {
@ -6710,7 +6710,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
// Keep going until we're out of reflow commands, or we've run
// past our deadline.
} while (mDirtyRoots.Count() &&
} while (mDirtyRoots.Length() &&
(!aInterruptible || PR_IntervalNow() < deadline));
// XXXwaterson for interruptible reflow, examine the tree and
@ -6739,7 +6739,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
// after DidDoReflow(), since that method can change whether there are
// dirty roots around by flushing, and there's no point in posting a
// reflow event just to have the flush revoke it.
if (mDirtyRoots.Count())
if (mDirtyRoots.Length())
PostReflowEvent();
}
}
@ -6748,7 +6748,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
MOZ_TIMER_STOP(mReflowWatch);
if (!mIsDestroying && mShouldUnsuppressPainting &&
mDirtyRoots.Count() == 0) {
mDirtyRoots.Length() == 0) {
// We only unlock if we're out of reflows. It's pointless
// to unlock if reflows are still pending, since reflows
// are just going to thrash the frames around some more. By

Просмотреть файл

@ -44,7 +44,6 @@
class nsPresContext;
class nsString;
class nsIContent;
class nsVoidArray;
class nsCSSFrameConstructor;
/**

Просмотреть файл

@ -63,9 +63,6 @@ class nsIDOMHTMLOptionsCollection;
class nsIDOMHTMLOptionElement;
class nsIComboboxControlFrame;
class nsPresContext;
class nsVoidArray;
class nsVoidArray;
class nsListEventListener;
/**

Просмотреть файл

@ -6715,7 +6715,7 @@ nsBlockFrame::CheckFloats(nsBlockReflowState& aState)
PRBool anyLineDirty = PR_FALSE;
// Check that the float list is what we would have built
nsAutoVoidArray lineFloats;
nsAutoTArray<nsIFrame*, 8> lineFloats;
for (line_iterator line = begin_lines(), line_end = end_lines();
line != line_end; ++line) {
if (line->HasFloats()) {
@ -6731,25 +6731,25 @@ nsBlockFrame::CheckFloats(nsBlockReflowState& aState)
}
}
nsAutoVoidArray storedFloats;
nsAutoTArray<nsIFrame*, 8> storedFloats;
PRBool equal = PR_TRUE;
PRInt32 i = 0;
PRUint32 i = 0;
for (nsIFrame* f = mFloats.FirstChild(); f; f = f->GetNextSibling()) {
storedFloats.AppendElement(f);
if (i < lineFloats.Count() && lineFloats.ElementAt(i) != f) {
if (i < lineFloats.Length() && lineFloats.ElementAt(i) != f) {
equal = PR_FALSE;
}
++i;
}
if ((!equal || lineFloats.Count() != storedFloats.Count()) && !anyLineDirty) {
if ((!equal || lineFloats.Length() != storedFloats.Length()) && !anyLineDirty) {
NS_WARNING("nsBlockFrame::CheckFloats: Explicit float list is out of sync with float cache");
#if defined(DEBUG_roc)
nsIFrameDebug::RootFrameList(PresContext(), stdout, 0);
for (i = 0; i < lineFloats.Count(); ++i) {
for (i = 0; i < lineFloats.Length(); ++i) {
printf("Line float: %p\n", lineFloats.ElementAt(i));
}
for (i = 0; i < storedFloats.Count(); ++i) {
for (i = 0; i < storedFloats.Length(); ++i) {
printf("Stored float: %p\n", storedFloats.ElementAt(i));
}
#endif

Просмотреть файл

@ -1147,12 +1147,12 @@ nsContainerFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
// with very many next-in-flows
nsIFrame* nextNextInFlow = aNextInFlow->GetNextInFlow();
if (nextNextInFlow) {
nsAutoVoidArray frames;
nsAutoTArray<nsIFrame*, 8> frames;
for (nsIFrame* f = nextNextInFlow; f; f = f->GetNextInFlow()) {
frames.AppendElement(f);
}
for (PRInt32 i = frames.Count() - 1; i >= 0; --i) {
nsIFrame* delFrame = static_cast<nsIFrame*>(frames.ElementAt(i));
for (PRInt32 i = frames.Length() - 1; i >= 0; --i) {
nsIFrame* delFrame = frames.ElementAt(i);
static_cast<nsContainerFrame*>(delFrame->GetParent())
->DeleteNextInFlowChild(aPresContext, delFrame, aDeletingEmptyFrames);
}

Просмотреть файл

@ -2917,8 +2917,8 @@ nsIFrame::InlineMinWidthData::ForceBreak(nsIRenderingContext *aRenderingContext)
prevLines = PR_MAX(prevLines, currentLine);
currentLine = trailingWhitespace = 0;
for (PRInt32 i = 0, i_end = floats.Count(); i != i_end; ++i) {
nsIFrame *floatFrame = static_cast<nsIFrame*>(floats[i]);
for (PRUint32 i = 0, i_end = floats.Length(); i != i_end; ++i) {
nsIFrame *floatFrame = floats[i];
nscoord float_min =
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, floatFrame,
nsLayoutUtils::MIN_WIDTH);
@ -2948,7 +2948,7 @@ nsIFrame::InlineMinWidthData::OptionallyBreak(nsIRenderingContext *aRenderingCon
void
nsIFrame::InlinePrefWidthData::ForceBreak(nsIRenderingContext *aRenderingContext)
{
if (floats.Count() != 0) {
if (floats.Length() != 0) {
// preferred widths accumulated for floats that have already
// been cleared past
nscoord floats_done = 0,
@ -2957,8 +2957,8 @@ nsIFrame::InlinePrefWidthData::ForceBreak(nsIRenderingContext *aRenderingContext
floats_cur_left = 0,
floats_cur_right = 0;
for (PRInt32 i = 0, i_end = floats.Count(); i != i_end; ++i) {
nsIFrame *floatFrame = static_cast<nsIFrame*>(floats[i]);
for (PRUint32 i = 0, i_end = floats.Length(); i != i_end; ++i) {
nsIFrame *floatFrame = floats[i];
const nsStyleDisplay *floatDisp = floatFrame->GetStyleDisplay();
if (floatDisp->mBreakType == NS_STYLE_CLEAR_LEFT ||
floatDisp->mBreakType == NS_STYLE_CLEAR_RIGHT ||
@ -6946,8 +6946,8 @@ struct DR_State
char* aBuf);
DR_Rule* ParseRule(FILE* aFile);
void ParseRulesFile();
void AddRule(nsVoidArray& aRules,
DR_Rule& aRule);
void AddRule(nsTArray<DR_Rule*>& aRules,
DR_Rule& aRule);
PRBool IsWhiteSpace(int c);
PRBool GetNumber(char* aBuf,
PRInt32& aNumber);
@ -6960,15 +6960,14 @@ struct DR_State
PRBool mInited;
PRBool mActive;
PRInt32 mCount;
nsVoidArray mWildRules;
PRInt32 mAssert;
PRInt32 mIndent;
PRBool mIndentUndisplayedFrames;
nsVoidArray mFrameTypeTable;
PRBool mDisplayPixelErrors;
nsTArray<DR_Rule*> mWildRules;
nsTArray<DR_FrameTypeInfo*> mFrameTypeTable;
// reflow specific state
nsVoidArray mFrameTreeLeaves;
nsTArray<DR_FrameTreeNode*> mFrameTreeLeaves;
};
static DR_State *DR_state; // the one and only DR_State
@ -7020,16 +7019,16 @@ struct DR_FrameTypeInfo
~DR_FrameTypeInfo() {
MOZ_COUNT_DTOR(DR_FrameTypeInfo);
PRInt32 numElements;
numElements = mRules.Count();
numElements = mRules.Length();
for (PRInt32 i = numElements - 1; i >= 0; i--) {
delete (DR_Rule *)mRules.ElementAt(i);
delete mRules.ElementAt(i);
}
}
nsIAtom* mType;
char mNameAbbrev[16];
char mName[32];
nsVoidArray mRules;
nsTArray<DR_Rule*> mRules;
};
DR_FrameTypeInfo::DR_FrameTypeInfo(nsIAtom* aFrameType,
@ -7113,17 +7112,17 @@ DR_State::~DR_State()
{
MOZ_COUNT_DTOR(DR_State);
PRInt32 numElements, i;
numElements = mWildRules.Count();
numElements = mWildRules.Length();
for (i = numElements - 1; i >= 0; i--) {
delete (DR_Rule *)mWildRules.ElementAt(i);
delete mWildRules.ElementAt(i);
}
numElements = mFrameTreeLeaves.Count();
numElements = mFrameTreeLeaves.Length();
for (i = numElements - 1; i >= 0; i--) {
delete (DR_FrameTreeNode *)mFrameTreeLeaves.ElementAt(i);
delete mFrameTreeLeaves.ElementAt(i);
}
numElements = mFrameTypeTable.Count();
numElements = mFrameTypeTable.Length();
for (i = numElements - 1; i >= 0; i--) {
delete (DR_FrameTypeInfo *)mFrameTypeTable.ElementAt(i);
delete mFrameTypeTable.ElementAt(i);
}
}
@ -7210,15 +7209,15 @@ DR_Rule* DR_State::ParseRule(FILE* aFile)
return rule;
}
void DR_State::AddRule(nsVoidArray& aRules,
DR_Rule& aRule)
void DR_State::AddRule(nsTArray<DR_Rule*>& aRules,
DR_Rule& aRule)
{
PRInt32 numRules = aRules.Count();
PRInt32 numRules = aRules.Length();
for (PRInt32 ruleX = 0; ruleX < numRules; ruleX++) {
DR_Rule* rule = (DR_Rule*)aRules.ElementAt(ruleX);
DR_Rule* rule = aRules.ElementAt(ruleX);
NS_ASSERTION(rule, "program error");
if (aRule.mLength > rule->mLength) {
aRules.InsertElementAt(&aRule, ruleX);
aRules.InsertElementAt(ruleX, &aRule);
return;
}
}
@ -7260,28 +7259,28 @@ void DR_State::AddFrameTypeInfo(nsIAtom* aFrameType,
DR_FrameTypeInfo* DR_State::GetFrameTypeInfo(nsIAtom* aFrameType)
{
PRInt32 numEntries = mFrameTypeTable.Count();
PRInt32 numEntries = mFrameTypeTable.Length();
NS_ASSERTION(numEntries != 0, "empty FrameTypeTable");
for (PRInt32 i = 0; i < numEntries; i++) {
DR_FrameTypeInfo* info = (DR_FrameTypeInfo*)mFrameTypeTable.ElementAt(i);
DR_FrameTypeInfo* info = mFrameTypeTable.ElementAt(i);
if (info && (info->mType == aFrameType)) {
return info;
}
}
return (DR_FrameTypeInfo*)mFrameTypeTable.ElementAt(numEntries - 1); // return unknown frame type
return mFrameTypeTable.ElementAt(numEntries - 1); // return unknown frame type
}
DR_FrameTypeInfo* DR_State::GetFrameTypeInfo(char* aFrameName)
{
PRInt32 numEntries = mFrameTypeTable.Count();
PRInt32 numEntries = mFrameTypeTable.Length();
NS_ASSERTION(numEntries != 0, "empty FrameTypeTable");
for (PRInt32 i = 0; i < numEntries; i++) {
DR_FrameTypeInfo* info = (DR_FrameTypeInfo*)mFrameTypeTable.ElementAt(i);
DR_FrameTypeInfo* info = mFrameTypeTable.ElementAt(i);
if (info && ((strcmp(aFrameName, info->mName) == 0) || (strcmp(aFrameName, info->mNameAbbrev) == 0))) {
return info;
}
}
return (DR_FrameTypeInfo*)mFrameTypeTable.ElementAt(numEntries - 1); // return unknown frame type
return mFrameTypeTable.ElementAt(numEntries - 1); // return unknown frame type
}
void DR_State::InitFrameTypeTable()
@ -7383,9 +7382,9 @@ void DR_State::FindMatchingRule(DR_FrameTreeNode& aNode)
DR_FrameTypeInfo* info = GetFrameTypeInfo(aNode.mFrame->GetType());
NS_ASSERTION(info, "program error");
PRInt32 numRules = info->mRules.Count();
PRInt32 numRules = info->mRules.Length();
for (PRInt32 ruleX = 0; ruleX < numRules; ruleX++) {
DR_Rule* rule = (DR_Rule*)info->mRules.ElementAt(ruleX);
DR_Rule* rule = info->mRules.ElementAt(ruleX);
if (rule && RuleMatches(*rule, aNode)) {
aNode.mDisplay = rule->mDisplay;
matchingRule = PR_TRUE;
@ -7393,9 +7392,9 @@ void DR_State::FindMatchingRule(DR_FrameTreeNode& aNode)
}
}
if (!matchingRule) {
PRInt32 numWildRules = mWildRules.Count();
PRInt32 numWildRules = mWildRules.Length();
for (PRInt32 ruleX = 0; ruleX < numWildRules; ruleX++) {
DR_Rule* rule = (DR_Rule*)mWildRules.ElementAt(ruleX);
DR_Rule* rule = mWildRules.ElementAt(ruleX);
if (rule && RuleMatches(*rule, aNode)) {
aNode.mDisplay = rule->mDisplay;
break;
@ -7420,8 +7419,8 @@ DR_FrameTreeNode* DR_State::CreateTreeNode(nsIFrame* aFrame,
DR_FrameTreeNode* parentNode = nsnull;
DR_FrameTreeNode* lastLeaf = nsnull;
if(mFrameTreeLeaves.Count())
lastLeaf = (DR_FrameTreeNode*)mFrameTreeLeaves.ElementAt(mFrameTreeLeaves.Count() - 1);
if(mFrameTreeLeaves.Length())
lastLeaf = (DR_FrameTreeNode*)mFrameTreeLeaves.ElementAt(mFrameTreeLeaves.Length() - 1);
if (lastLeaf) {
for (parentNode = lastLeaf; parentNode && (parentNode->mFrame != parentFrame); parentNode = parentNode->mParent) {
}
@ -7435,7 +7434,7 @@ DR_FrameTreeNode* DR_State::CreateTreeNode(nsIFrame* aFrame,
}
if (lastLeaf && (lastLeaf == parentNode)) {
mFrameTreeLeaves.RemoveElementAt(mFrameTreeLeaves.Count() - 1);
mFrameTreeLeaves.RemoveElementAt(mFrameTreeLeaves.Length() - 1);
}
mFrameTreeLeaves.AppendElement(newNode);
mCount++;
@ -7463,8 +7462,8 @@ void DR_State::PrettyUC(nscoord aSize,
void DR_State::DeleteTreeNode(DR_FrameTreeNode& aNode)
{
mFrameTreeLeaves.RemoveElement(&aNode);
PRInt32 numLeaves = mFrameTreeLeaves.Count();
if ((0 == numLeaves) || (aNode.mParent != (DR_FrameTreeNode*)mFrameTreeLeaves.ElementAt(numLeaves - 1))) {
PRInt32 numLeaves = mFrameTreeLeaves.Length();
if ((0 == numLeaves) || (aNode.mParent != mFrameTreeLeaves.ElementAt(numLeaves - 1))) {
mFrameTreeLeaves.AppendElement(aNode.mParent);
}

Просмотреть файл

@ -327,27 +327,25 @@ nsFrameList::GetLength() const
return count;
}
static int CompareByContentOrder(const void* aF1, const void* aF2, void* aDummy)
static int CompareByContentOrder(const nsIFrame* aF1, const nsIFrame* aF2)
{
const nsIFrame* f1 = static_cast<const nsIFrame*>(aF1);
const nsIFrame* f2 = static_cast<const nsIFrame*>(aF2);
if (f1->GetContent() != f2->GetContent()) {
return nsLayoutUtils::CompareTreePosition(f1->GetContent(), f2->GetContent());
if (aF1->GetContent() != aF2->GetContent()) {
return nsLayoutUtils::CompareTreePosition(aF1->GetContent(), aF2->GetContent());
}
if (f1 == f2) {
if (aF1 == aF2) {
return 0;
}
const nsIFrame* f;
for (f = f2; f; f = f->GetPrevInFlow()) {
if (f == f1) {
for (f = aF2; f; f = f->GetPrevInFlow()) {
if (f == aF1) {
// f1 comes before f2 in the flow
return -1;
}
}
for (f = f1; f; f = f->GetPrevInFlow()) {
if (f == f2) {
for (f = aF1; f; f = f->GetPrevInFlow()) {
if (f == aF2) {
// f1 comes after f2 in the flow
return 1;
}
@ -357,21 +355,32 @@ static int CompareByContentOrder(const void* aF1, const void* aF2, void* aDummy)
return 0;
}
class CompareByContentOrderComparator
{
public:
PRBool Equals(const nsIFrame* aA, const nsIFrame* aB) const {
return aA == aB;
}
PRBool LessThan(const nsIFrame* aA, const nsIFrame* aB) const {
return CompareByContentOrder(aA, aB) < 0;
}
};
void
nsFrameList::SortByContentOrder()
{
if (!mFirstChild)
return;
nsAutoVoidArray array;
nsAutoTArray<nsIFrame*, 8> array;
nsIFrame* f;
for (f = mFirstChild; f; f = f->GetNextSibling()) {
array.AppendElement(f);
}
array.Sort(CompareByContentOrder, nsnull);
f = mFirstChild = static_cast<nsIFrame*>(array.FastElementAt(0));
for (PRInt32 i = 1; i < array.Count(); ++i) {
nsIFrame* ff = static_cast<nsIFrame*>(array.FastElementAt(i));
array.Sort(CompareByContentOrderComparator());
f = mFirstChild = array.ElementAt(0);
for (PRUint32 i = 1; i < array.Length(); ++i) {
nsIFrame* ff = array.ElementAt(i);
f->SetNextSibling(ff);
f = ff;
}

Просмотреть файл

@ -1201,7 +1201,7 @@ public:
nscoord trailingWhitespace;
// Floats encountered in the lines.
nsVoidArray floats; // of nsIFrame*
nsTArray<nsIFrame*> floats;
};
struct InlineMinWidthData : public InlineIntrinsicWidthData {

Просмотреть файл

@ -721,7 +721,7 @@ nsImageMap::nsImageMap() :
nsImageMap::~nsImageMap()
{
NS_ASSERTION(mAreas.Count() == 0, "Destroy was not called");
NS_ASSERTION(mAreas.Length() == 0, "Destroy was not called");
}
NS_IMPL_ISUPPORTS4(nsImageMap,
@ -738,9 +738,9 @@ nsImageMap::GetBoundsForAreaContent(nsIContent *aContent,
NS_ENSURE_TRUE(aContent && aPresContext, NS_ERROR_INVALID_ARG);
// Find the Area struct associated with this content node, and return bounds
PRInt32 i, n = mAreas.Count();
PRUint32 i, n = mAreas.Length();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
Area* area = mAreas.ElementAt(i);
if (area->mArea == aContent) {
aBounds = nsRect();
nsIPresShell* shell = aPresContext->PresShell();
@ -761,9 +761,9 @@ nsImageMap::FreeAreas()
{
nsFrameManager *frameManager = mPresShell->FrameManager();
PRInt32 i, n = mAreas.Count();
PRUint32 i, n = mAreas.Length();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
Area* area = mAreas.ElementAt(i);
frameManager->RemoveAsPrimaryFrame(area->mArea, mImageFrame);
nsCOMPtr<nsIContent> areaContent;
@ -912,9 +912,9 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
nsIContent** aContent) const
{
NS_ASSERTION(mMap, "Not initialized");
PRInt32 i, n = mAreas.Count();
PRUint32 i, n = mAreas.Length();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
Area* area = mAreas.ElementAt(i);
if (area->IsInside(aX, aY)) {
area->GetArea(aContent);
@ -928,9 +928,9 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
void
nsImageMap::Draw(nsIFrame* aFrame, nsIRenderingContext& aRC)
{
PRInt32 i, n = mAreas.Count();
PRUint32 i, n = mAreas.Length();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
Area* area = mAreas.ElementAt(i);
area->Draw(aFrame, aRC);
}
}
@ -1011,9 +1011,9 @@ nsImageMap::ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus)
if (NS_SUCCEEDED(aEvent->GetTarget(getter_AddRefs(target))) && target) {
nsCOMPtr<nsIContent> targetContent(do_QueryInterface(target));
if (targetContent) {
PRInt32 i, n = mAreas.Count();
PRUint32 i, n = mAreas.Length();
for (i = 0; i < n; i++) {
Area* area = (Area*) mAreas.ElementAt(i);
Area* area = mAreas.ElementAt(i);
nsCOMPtr<nsIContent> areaContent;
area->GetArea(getter_AddRefs(areaContent));
if (areaContent.get() == targetContent.get()) {

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsStubMutationObserver.h"
#include "nsIDOMFocusListener.h"
#include "nsIFrame.h"
@ -55,6 +55,7 @@ class nsIRenderingContext;
class nsIURI;
class nsString;
class nsIDOMEvent;
class Area;
class nsImageMap : public nsStubMutationObserver, public nsIDOMFocusListener,
public nsIImageMap
@ -118,7 +119,7 @@ protected:
nsIPresShell* mPresShell; // WEAK - owns the frame that owns us
nsIFrame* mImageFrame; // the frame that owns us
nsCOMPtr<nsIContent> mMap;
nsAutoVoidArray mAreas; // almost always has some entries
nsAutoTArray<Area*, 8> mAreas; // almost always has some entries
PRBool mContainsBlockContents;
};

Просмотреть файл

@ -67,7 +67,7 @@
#include "nsIRenderingContext.h"
#include "nsIPresShell.h"
#include "nsITimer.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIDOMText.h"
#include "nsIDocument.h"
#include "nsIDeviceContext.h"
@ -2747,7 +2747,7 @@ protected:
};
nsCOMPtr<nsITimer> mTimer;
nsVoidArray mFrames;
nsTArray<FrameData*> mFrames;
nsPresContext* mPresContext;
protected:
@ -2796,32 +2796,31 @@ NS_IMPL_ISUPPORTS1(nsBlinkTimer, nsITimerCallback)
void nsBlinkTimer::AddFrame(nsPresContext* aPresContext, nsIFrame* aFrame) {
FrameData* frameData = new FrameData(aPresContext, aFrame);
mFrames.AppendElement(frameData);
if (1 == mFrames.Count()) {
if (1 == mFrames.Length()) {
Start();
}
}
PRBool nsBlinkTimer::RemoveFrame(nsIFrame* aFrame) {
PRInt32 i, n = mFrames.Count();
PRBool rv = PR_FALSE;
PRUint32 i, n = mFrames.Length();
for (i = 0; i < n; i++) {
FrameData* frameData = (FrameData*) mFrames.ElementAt(i);
FrameData* frameData = mFrames.ElementAt(i);
if (frameData->mFrame == aFrame) {
rv = mFrames.RemoveElementAt(i);
mFrames.RemoveElementAt(i);
delete frameData;
break;
}
}
if (0 == mFrames.Count()) {
if (0 == mFrames.Length()) {
Stop();
}
return rv;
return PR_TRUE;
}
PRInt32 nsBlinkTimer::FrameCount() {
return mFrames.Count();
return PRInt32(mFrames.Length());
}
NS_IMETHODIMP nsBlinkTimer::Notify(nsITimer *timer)
@ -2844,9 +2843,9 @@ NS_IMETHODIMP nsBlinkTimer::Notify(nsITimer *timer)
printf("%s\n", buf);
#endif
PRInt32 i, n = mFrames.Count();
PRUint32 i, n = mFrames.Length();
for (i = 0; i < n; i++) {
FrameData* frameData = (FrameData*) mFrames.ElementAt(i);
FrameData* frameData = mFrames.ElementAt(i);
// Determine damaged area and tell view manager to redraw it
// blink doesn't blink outline ... I hope

Просмотреть файл

@ -173,7 +173,7 @@ NS_IMETHODIMP
inCSSValueSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval)
{
if (mHoldResults) {
nsAutoString* result = (nsAutoString*)mResults->ElementAt(aIndex);
nsAutoString* result = mResults->ElementAt(aIndex);
_retval = *result;
} else if (aIndex == mResultCount-1) {
_retval = mLastResult;
@ -288,7 +288,7 @@ nsresult
inCSSValueSearch::InitSearch()
{
if (mHoldResults) {
mResults = new nsVoidArray();
mResults = new nsTArray<nsAutoString *>();
}
mResultCount = 0;

Просмотреть файл

@ -44,7 +44,7 @@
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "inISearchObserver.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIInspectorCSSUtils.h"
class nsIDOMCSSStyleSheet;
@ -66,7 +66,7 @@ protected:
nsCOMPtr<inISearchObserver> mObserver;
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;
nsCOMPtr<nsIDOMDocument> mDocument;
nsVoidArray* mResults;
nsTArray<nsAutoString *>* mResults;
nsCSSProperty* mProperties;
nsString mLastResult;
nsString mBaseURL;

Просмотреть файл

@ -980,13 +980,13 @@ inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsICon
inDOMViewNode*
inDOMView::GetNodeAt(PRInt32 aRow)
{
return (inDOMViewNode*)mNodes.ElementAt(aRow);
return mNodes.ElementAt(aRow);
}
PRInt32
inDOMView::GetRowCount()
{
return mNodes.Count();
return mNodes.Length();
}
PRInt32
@ -1026,7 +1026,7 @@ inDOMView::InsertNode(inDOMViewNode* aNode, PRInt32 aRow)
if (RowOutOfBounds(aRow, 1))
AppendNode(aNode);
else
mNodes.InsertElementAt(aNode, aRow);
mNodes.InsertElementAt(aRow, aNode);
}
void
@ -1046,16 +1046,16 @@ inDOMView::ReplaceNode(inDOMViewNode* aNode, PRInt32 aRow)
return;
delete GetNodeAt(aRow);
mNodes.ReplaceElementAt(aNode, aRow);
mNodes.ReplaceElementsAt(aRow, 1, aNode);
}
void
inDOMView::InsertNodes(nsVoidArray& aNodes, PRInt32 aRow)
inDOMView::InsertNodes(nsTArray<inDOMViewNode*>& aNodes, PRInt32 aRow)
{
if (aRow < 0 || aRow > GetRowCount())
return;
mNodes.InsertElementsAt(aNodes, aRow);
mNodes.InsertElementsAt(aRow, aNodes);
}
void
@ -1094,14 +1094,14 @@ inDOMView::ExpandNode(PRInt32 aRow)
kids);
PRInt32 kidCount = kids.Count();
nsVoidArray list(kidCount);
nsTArray<inDOMViewNode*> list(kidCount);
inDOMViewNode* newNode = nsnull;
inDOMViewNode* prevNode = nsnull;
for (PRInt32 i = 0; i < kidCount; ++i) {
newNode = CreateNode(kids[i], node);
list.ReplaceElementAt(newNode, i);
list.ReplaceElementsAt(i, 1, newNode);
if (prevNode)
prevNode->next = newNode;

Просмотреть файл

@ -46,7 +46,7 @@
#include "nsStubMutationObserver.h"
#include "nsIDOMNode.h"
#include "nsIDOMDocument.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsCOMArray.h"
#include "nsStaticAtom.h"
@ -104,7 +104,7 @@ protected:
nsCOMPtr<nsIDOMNode> mRootNode;
nsCOMPtr<nsIDOMDocument> mRootDocument;
nsVoidArray mNodes;
nsTArray<inDOMViewNode*> mNodes;
inDOMViewNode* GetNodeAt(PRInt32 aIndex);
PRInt32 GetRowCount();
@ -115,7 +115,7 @@ protected:
void InsertNode(inDOMViewNode* aNode, PRInt32 aIndex);
void RemoveNode(PRInt32 aIndex);
void ReplaceNode(inDOMViewNode* aNode, PRInt32 aIndex);
void InsertNodes(nsVoidArray& aNodes, PRInt32 aIndex);
void InsertNodes(nsTArray<inDOMViewNode*>& aNodes, PRInt32 aIndex);
void RemoveNodes(PRInt32 aIndex, PRInt32 aCount);
void RemoveAllNodes();
void ExpandNode(PRInt32 aRow);

Просмотреть файл

@ -74,8 +74,8 @@ inDeepTreeWalker::inDeepTreeWalker()
inDeepTreeWalker::~inDeepTreeWalker()
{
for (PRInt32 i = mStack.Count() - 1; i >= 0; --i) {
delete static_cast<DeepTreeStackItem*>(mStack[i]);
for (PRInt32 i = mStack.Length() - 1; i >= 0; --i) {
delete mStack[i];
}
}
@ -228,15 +228,15 @@ inDeepTreeWalker::NextNode(nsIDOMNode **_retval)
nsCOMPtr<nsIDOMNode> next;
while (1) {
DeepTreeStackItem* top = (DeepTreeStackItem*)mStack.ElementAt(mStack.Count()-1);
DeepTreeStackItem* top = mStack.ElementAt(mStack.Length()-1);
nsCOMPtr<nsIDOMNodeList> kids = top->kids;
PRUint32 childCount;
kids->GetLength(&childCount);
if (top->lastIndex == childCount) {
mStack.RemoveElementAt(mStack.Count()-1);
mStack.RemoveElementAt(mStack.Length()-1);
delete top;
if (mStack.Count() == 0) {
if (mStack.Length() == 0) {
mCurrentNode = nsnull;
break;
}
@ -288,7 +288,7 @@ inDeepTreeWalker::PushNode(nsIDOMNode* aNode)
item->kids = kids;
item->lastIndex = 0;
mStack.AppendElement((void*)item);
mStack.AppendElement(item);
}
/*

Просмотреть файл

@ -42,9 +42,10 @@
#include "nsCOMPtr.h"
#include "nsIDOMNode.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
class inIDOMUtils;
class DeepTreeStackItem;
class inDeepTreeWalker : public inIDeepTreeWalker
{
@ -65,7 +66,7 @@ protected:
nsCOMPtr<nsIDOMNode> mCurrentNode;
PRUint32 mWhatToShow;
nsAutoVoidArray mStack;
nsAutoTArray<DeepTreeStackItem*, 8> mStack;
nsCOMPtr<inIDOMUtils> mDOMUtils;
};

Просмотреть файл

@ -81,7 +81,7 @@ nsMathMLmmultiscriptsFrame::TransmitAutomaticData()
// the compression flag in them.
PRInt32 count = 0;
PRBool isSubScript = PR_FALSE;
nsAutoVoidArray subScriptFrames;
nsAutoTArray<nsIFrame*, 8> subScriptFrames;
nsIFrame* childFrame = mFrames.FirstChild();
while (childFrame) {
if (childFrame->GetContent()->Tag() == nsGkAtoms::mprescripts_) {
@ -104,8 +104,8 @@ nsMathMLmmultiscriptsFrame::TransmitAutomaticData()
count++;
childFrame = childFrame->GetNextSibling();
}
for (PRInt32 i = subScriptFrames.Count() - 1; i >= 0; i--) {
childFrame = (nsIFrame*)subScriptFrames[i];
for (PRInt32 i = subScriptFrames.Length() - 1; i >= 0; i--) {
childFrame = subScriptFrames[i];
PropagatePresentationDataFor(childFrame,
NS_MATHML_COMPRESSED, NS_MATHML_COMPRESSED);
}

Просмотреть файл

@ -46,7 +46,7 @@
#include "nsIRenderingContext.h"
#include "nsIFontMetrics.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsCSSFrameConstructor.h"
#include "nsTableOuterFrame.h"
#include "nsTableFrame.h"
@ -64,8 +64,8 @@
// aOffset[0] is the first string, aOffset[1] is the second string, etc.
// Used to parse attributes like columnalign='left right', rowalign='top bottom'
static void
SplitString(nsString& aString, // [IN/OUT]
nsVoidArray& aOffset) // [OUT]
SplitString(nsString& aString, // [IN/OUT]
nsTArray<PRUnichar*>& aOffset) // [OUT]
{
static const PRUnichar kNullCh = PRUnichar('\0');
@ -95,8 +95,8 @@ SplitString(nsString& aString, // [IN/OUT]
struct nsValueList
{
nsString mData;
nsVoidArray mArray;
nsString mData;
nsTArray<PRUnichar*> mArray;
nsValueList(nsString& aData) {
mData.Assign(aData);
@ -133,16 +133,16 @@ GetValueAt(nsIFrame* aTableOrRowFrame,
aTableOrRowFrame->GetContent()->GetAttr(kNameSpaceID_None, aAttribute, values);
if (!values.IsEmpty())
valueList = new nsValueList(values);
if (!valueList || !valueList->mArray.Count()) {
if (!valueList || !valueList->mArray.Length()) {
delete valueList; // ok either way, delete is null safe
return nsnull;
}
aTableOrRowFrame->SetProperty(aAttribute, valueList, DestroyValueListFunc);
}
PRInt32 count = valueList->mArray.Count();
PRInt32 count = valueList->mArray.Length();
return (aRowOrColIndex < count)
? (PRUnichar*)(valueList->mArray[aRowOrColIndex])
: (PRUnichar*)(valueList->mArray[count-1]);
? valueList->mArray[aRowOrColIndex]
: valueList->mArray[count-1];
}
#ifdef NS_DEBUG

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsHashtable.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIComponentManager.h"
@ -81,9 +80,9 @@ static PRInt32 gTableRefCount = 0;
static PRInt32 gOperatorCount = 0;
static OperatorData* gOperatorArray = nsnull;
static nsHashtable* gOperatorTable = nsnull;
static nsVoidArray* gStretchyOperatorArray = nsnull;
static nsTArray<nsString>* gInvariantCharArray = nsnull;
static PRBool gInitialized = PR_FALSE;
static nsTArray<OperatorData*>* gStretchyOperatorArray = nsnull;
static nsTArray<nsString>* gInvariantCharArray = nsnull;
static const PRUnichar kNullCh = PRUnichar('\0');
static const PRUnichar kDashCh = PRUnichar('#');
@ -378,7 +377,7 @@ InitGlobals()
gInitialized = PR_TRUE;
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
gInvariantCharArray = new nsTArray<nsString>();
gStretchyOperatorArray = new nsVoidArray();
gStretchyOperatorArray = new nsTArray<OperatorData*>();
if (gInvariantCharArray && gStretchyOperatorArray) {
gOperatorTable = new nsHashtable();
if (gOperatorTable) {
@ -566,7 +565,7 @@ nsMathMLOperators::CountStretchyOperator()
if (!gInitialized) {
InitGlobals();
}
return (gStretchyOperatorArray) ? gStretchyOperatorArray->Count() : 0;
return (gStretchyOperatorArray) ? gStretchyOperatorArray->Length() : 0;
}
PRInt32
@ -576,8 +575,8 @@ nsMathMLOperators::FindStretchyOperator(PRUnichar aOperator)
InitGlobals();
}
if (gStretchyOperatorArray) {
for (PRInt32 k = 0; k < gStretchyOperatorArray->Count(); k++) {
OperatorData* data = (OperatorData*)gStretchyOperatorArray->ElementAt(k);
for (PRUint32 k = 0; k < gStretchyOperatorArray->Length(); k++) {
OperatorData* data = gStretchyOperatorArray->ElementAt(k);
if (data && (aOperator == data->mStr[0])) {
return k;
}
@ -591,8 +590,9 @@ nsMathMLOperators::GetStretchyDirectionAt(PRInt32 aIndex)
{
NS_ASSERTION(gStretchyOperatorArray, "invalid call");
if (gStretchyOperatorArray) {
NS_ASSERTION(aIndex < gStretchyOperatorArray->Count(), "invalid call");
OperatorData* data = (OperatorData*)gStretchyOperatorArray->ElementAt(aIndex);
NS_ASSERTION(aIndex < PRInt32(gStretchyOperatorArray->Length()),
"invalid call");
OperatorData* data = gStretchyOperatorArray->ElementAt(aIndex);
if (data) {
if (NS_MATHML_OPERATOR_IS_STRETCHY_VERT(data->mFlags))
return NS_STRETCH_DIRECTION_VERTICAL;
@ -609,8 +609,9 @@ nsMathMLOperators::DisableStretchyOperatorAt(PRInt32 aIndex)
{
NS_ASSERTION(gStretchyOperatorArray, "invalid call");
if (gStretchyOperatorArray) {
NS_ASSERTION(aIndex < gStretchyOperatorArray->Count(), "invalid call");
gStretchyOperatorArray->ReplaceElementAt(nsnull, aIndex);
NS_ASSERTION(aIndex < PRInt32(gStretchyOperatorArray->Length()),
"invalid call");
(*gStretchyOperatorArray)[aIndex] = nsnull;
}
}

Просмотреть файл

@ -123,11 +123,6 @@ nsPrintData::~nsPrintData()
delete mPrintObject;
if (mPrintDocList != nsnull) {
mPrintDocList->Clear();
delete mPrintDocList;
}
if (mBrandName) {
NS_Free(mBrandName);
}

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsIDeviceContext.h"
#include "nsIPrintProgressParams.h"
#include "nsIPrintOptions.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsCOMArray.h"
// Classes
@ -102,7 +102,7 @@ public:
nsCOMPtr<nsIDOMWindow> mCurrentFocusWin; // cache a pointer to the currently focused window
nsVoidArray* mPrintDocList;
nsTArray<nsPrintObject*> mPrintDocList;
PRPackedBool mIsIFrameSelected;
PRPackedBool mIsParentAFrameSet;
PRPackedBool mOnStartSent;

Просмотреть файл

@ -201,7 +201,7 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified
#ifdef EXTENDED_DEBUG_PRINTING
// Forward Declarations
static void DumpPrintObjectsListStart(const char * aStr, nsVoidArray * aDocList);
static void DumpPrintObjectsListStart(const char * aStr, nsTArray<nsPrintObject*> * aDocList);
static void DumpPrintObjectsTree(nsPrintObject * aPO, int aLevel= 0, FILE* aFD = nsnull);
static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,nsIDeviceContext * aDC, int aLevel= 0, FILE * aFD = nsnull);
@ -399,7 +399,7 @@ nsresult nsPrintEngine::GetSeqFrameAndCountPages(nsIFrame*& aSeqFrame, PRInt32&
static int RemoveFilesInDir(const char * aDir);
static void GetDocTitleAndURL(nsPrintObject* aPO, char *& aDocStr, char *& aURLStr);
static void DumpPrintObjectsTree(nsPrintObject * aPO, int aLevel, FILE* aFD);
static void DumpPrintObjectsList(nsVoidArray * aDocList);
static void DumpPrintObjectsList(nsTArray<nsPrintObject*> * aDocList);
static void RootFrameList(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent);
static void DumpViews(nsIDocShell* aDocShell, FILE* out);
static void DumpLayoutData(char* aTitleStr, char* aURLStr,
@ -508,9 +508,6 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview,
// Check to see if there is a "regular" selection
PRBool isSelection = IsThereARangeSelection(mPrt->mCurrentFocusWin);
mPrt->mPrintDocList = new nsVoidArray();
NS_ENSURE_TRUE(mPrt->mPrintDocList, NS_ERROR_OUT_OF_MEMORY);
// Get the docshell for this documentviewer
nsCOMPtr<nsIDocShell> webContainer(do_QueryInterface(mContainer, &rv));
NS_ENSURE_SUCCESS(rv, rv);
@ -520,7 +517,7 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview,
rv = mPrt->mPrintObject->Init(webContainer);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(mPrt->mPrintDocList->AppendElement(mPrt->mPrintObject),
NS_ENSURE_TRUE(mPrt->mPrintDocList.AppendElement(mPrt->mPrintObject),
NS_ERROR_OUT_OF_MEMORY);
mPrt->mIsParentAFrameSet = IsParentAFrameSet(webContainer);
@ -528,7 +525,7 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview,
// Build the "tree" of PrintObjects
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(webContainer));
BuildDocTree(parentAsNode, mPrt->mPrintDocList, mPrt->mPrintObject);
BuildDocTree(parentAsNode, &mPrt->mPrintDocList, mPrt->mPrintObject);
// XXX This isn't really correct...
if (!mPrt->mPrintObject->mDocument->GetRootContent())
@ -827,13 +824,13 @@ nsPrintEngine::EnumerateDocumentNames(PRUint32* aCount,
*aCount = 0;
*aResult = nsnull;
PRInt32 numDocs = mPrt->mPrintDocList->Count();
PRInt32 numDocs = mPrt->mPrintDocList.Length();
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numDocs * sizeof(PRUnichar*));
if (!array)
return NS_ERROR_OUT_OF_MEMORY;
for (PRInt32 i=0;i<numDocs;i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
PRUnichar * docTitleStr;
PRUnichar * docURLStr;
@ -1103,9 +1100,9 @@ nsPrintEngine::IsParentAFrameSet(nsIDocShell * aParent)
// Recursively build a list of sub documents to be printed
// that mirrors the document tree
void
nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
nsVoidArray * aDocList,
nsPrintObject * aPO)
nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
nsTArray<nsPrintObject*> * aDocList,
nsPrintObject * aPO)
{
NS_ASSERTION(aParentNode, "Pointer is null!");
NS_ASSERTION(aDocList, "Pointer is null!");
@ -1200,8 +1197,8 @@ nsPrintEngine::MapContentToWebShells(nsPrintObject* aRootPO,
}
// Continue recursively walking the chilren of this PO
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
MapContentToWebShells(aRootPO, (nsPrintObject*)aPO->mKids[i]);
for (PRUint32 i=0;i<aPO->mKids.Length();i++) {
MapContentToWebShells(aRootPO, aPO->mKids[i]);
}
}
@ -1227,8 +1224,8 @@ nsPrintEngine::CheckForChildFrameSets(nsPrintObject* aPO)
// Continue recursively walking the chilren of this PO
PRBool hasChildFrames = PR_FALSE;
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)aPO->mKids[i];
for (PRUint32 i=0;i<aPO->mKids.Length();i++) {
nsPrintObject* po = aPO->mKids[i];
if (po->mFrameType == eFrame) {
hasChildFrames = PR_TRUE;
CheckForChildFrameSets(po);
@ -1273,9 +1270,9 @@ nsPrintEngine::MapContentForPO(nsPrintObject* aPO,
if (docShell) {
nsPrintObject * po = nsnull;
PRInt32 cnt = aPO->mKids.Count();
PRInt32 cnt = aPO->mKids.Length();
for (PRInt32 i=0;i<cnt;i++) {
nsPrintObject* kid = (nsPrintObject*)aPO->mKids.ElementAt(i);
nsPrintObject* kid = aPO->mKids.ElementAt(i);
if (kid->mDocument == subDoc) {
po = kid;
break;
@ -1353,8 +1350,8 @@ nsPrintEngine::SetPrintPO(nsPrintObject* aPO, PRBool aPrint)
// Set whether to print flag
aPO->mDontPrint = !aPrint;
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
SetPrintPO((nsPrintObject*)aPO->mKids[i], aPrint);
for (PRUint32 i=0;i<aPO->mKids.Length();i++) {
SetPrintPO(aPO->mKids[i], aPrint);
}
}
@ -1623,7 +1620,7 @@ nsPrintEngine::SetupToPrintContent()
// But skip this step if we are in PrintPreview
if (mPrt->mShrinkToFit && !ppIsShrinkToFit) {
// Now look for the PO that has the smallest percent for shrink to fit
if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
if (mPrt->mPrintDocList.Length() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
nsPrintObject* smallestPO = FindSmallestSTF();
NS_ASSERTION(smallestPO, "There must always be an XMost PO!");
if (smallestPO) {
@ -1640,8 +1637,8 @@ nsPrintEngine::SetupToPrintContent()
// Clamp Shrink to Fit to 60%
mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.60f);
for (PRInt32 i=0;i<mPrt->mPrintDocList->Count();i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
for (PRUint32 i=0;i<mPrt->mPrintDocList.Length();i++) {
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
// Wipe out the presentation before we reflow
po->DestroyPresentation();
@ -1668,7 +1665,7 @@ nsPrintEngine::SetupToPrintContent()
#ifdef PR_LOGGING
{
float calcRatio = 0.0f;
if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
if (mPrt->mPrintDocList.Length() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
nsPrintObject* smallestPO = FindSmallestSTF();
NS_ASSERTION(smallestPO, "There must always be an XMost PO!");
if (smallestPO) {
@ -1809,9 +1806,9 @@ nsPrintEngine::ReflowDocList(nsPrintObject* aPO, PRBool aSetPixelScale)
rv = ReflowPrintObject(aPO);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 cnt = aPO->mKids.Count();
PRInt32 cnt = aPO->mKids.Length();
for (PRInt32 i=0;i<cnt;i++) {
rv = ReflowDocList((nsPrintObject *)aPO->mKids[i], aSetPixelScale);
rv = ReflowDocList(aPO->mKids[i], aSetPixelScale);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
@ -2057,9 +2054,8 @@ nsPrintEngine::CalcNumPrintablePages(PRInt32& aNumPages)
aNumPages = 0;
// Count the number of printable documents
// and printable pages
PRInt32 i;
for (i=0; i<mPrt->mPrintDocList->Count(); i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
for (PRUint32 i=0; i<mPrt->mPrintDocList.Length(); i++) {
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
if (po->mPresContext && po->mPresContext->IsRootPaginatedDocument()) {
nsIPageSequenceFrame* pageSequence;
@ -2099,8 +2095,8 @@ nsPrintEngine::PrintDocContent(nsPrintObject* aPO, nsresult& aStatus)
// If |aPO->mPrintAsIs| and |aPO->mHasBeenPrinted| are true,
// the kids frames are already processed in |PrintPage|.
if (!aPO->mInvisible && !(aPO->mPrintAsIs && aPO->mHasBeenPrinted)) {
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)aPO->mKids[i];
for (PRUint32 i=0;i<aPO->mKids.Length();i++) {
nsPrintObject* po = aPO->mKids[i];
PRBool printed = PrintDocContent(po, aStatus);
if (printed || NS_FAILED(aStatus)) {
return PR_TRUE;
@ -2764,8 +2760,8 @@ nsPrintEngine::SetPrintAsIs(nsPrintObject* aPO, PRBool aAsIs)
NS_ASSERTION(aPO, "Pointer is null!");
aPO->mPrintAsIs = aAsIs;
for (PRInt32 i=0;i<aPO->mKids.Count();i++) {
SetPrintAsIs((nsPrintObject*)aPO->mKids[i], aAsIs);
for (PRUint32 i=0;i<aPO->mKids.Length();i++) {
SetPrintAsIs(aPO->mKids[i], aAsIs);
}
}
@ -2788,10 +2784,9 @@ nsPrintEngine::FindPrintObjectByDOMWin(nsPrintObject* aPO,
return aPO;
}
PRInt32 cnt = aPO->mKids.Count();
PRInt32 cnt = aPO->mKids.Length();
for (PRInt32 i = 0; i < cnt; ++i) {
nsPrintObject* po = FindPrintObjectByDOMWin((nsPrintObject*)aPO->mKids[i],
aDOMWin);
nsPrintObject* po = FindPrintObjectByDOMWin(aPO->mKids[i], aDOMWin);
if (po) {
return po;
}
@ -2850,9 +2845,9 @@ nsPrintEngine::EnablePOsForPrinting()
// Set the children so they are PrinAsIs
// In this case, the children are probably IFrames
if (mPrt->mPrintObject->mKids.Count() > 0) {
for (PRInt32 i=0;i<mPrt->mPrintObject->mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintObject->mKids[i];
if (mPrt->mPrintObject->mKids.Length() > 0) {
for (PRUint32 i=0;i<mPrt->mPrintObject->mKids.Length();i++) {
nsPrintObject* po = mPrt->mPrintObject->mKids[i];
NS_ASSERTION(po, "nsPrintObject can't be null!");
SetPrintAsIs(po);
}
@ -2900,8 +2895,8 @@ nsPrintEngine::EnablePOsForPrinting()
return NS_OK;
}
} else {
for (PRInt32 i=0;i<mPrt->mPrintDocList->Count();i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
for (PRUint32 i=0;i<mPrt->mPrintDocList.Length();i++) {
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(po->mDocShell);
if (IsThereARangeSelection(domWin)) {
@ -2968,7 +2963,7 @@ nsPrintEngine::EnablePOsForPrinting()
// NOTE: Calling this sets the "po" and
// we don't want to do this for documents that have no children,
// because then the "DoEndPage" gets called and it shouldn't
if (po->mKids.Count() > 0) {
if (po->mKids.Length() > 0) {
// Makes sure that itself, and all of its children are printed "AsIs"
SetPrintAsIs(po);
}
@ -2984,9 +2979,9 @@ nsPrintEngine::EnablePOsForPrinting()
// then don't print any of the FraneSet Docs
if (mPrt->mPrintFrameType == nsIPrintSettings::kEachFrameSep) {
SetPrintPO(mPrt->mPrintObject, PR_TRUE);
PRInt32 cnt = mPrt->mPrintDocList->Count();
PRInt32 cnt = mPrt->mPrintDocList.Length();
for (PRInt32 i=0;i<cnt;i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
if (po->mFrameType == eFrameSet) {
po->mDontPrint = PR_TRUE;
@ -3006,8 +3001,8 @@ nsPrintEngine::FindSmallestSTF()
float smallestRatio = 1.0f;
nsPrintObject* smallestPO = nsnull;
for (PRInt32 i=0;i<mPrt->mPrintDocList->Count();i++) {
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
for (PRUint32 i=0;i<mPrt->mPrintDocList.Length();i++) {
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
if (po->mFrameType != eFrameSet && po->mFrameType != eIFrame) {
if (po->mShrinkRatio < smallestRatio) {
@ -3040,8 +3035,8 @@ nsPrintEngine::TurnScriptingOn(PRBool aDoTurnOn)
NS_ASSERTION(mDocument, "We MUST have a document.");
// First, get the script global object from the document...
for (PRInt32 i=0;i<prt->mPrintDocList->Count();i++) {
nsPrintObject* po = (nsPrintObject*)prt->mPrintDocList->ElementAt(i);
for (PRUint32 i=0;i<prt->mPrintDocList.Length();i++) {
nsPrintObject* po = prt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsIDocument* doc = po->mDocument;
@ -3444,7 +3439,7 @@ void DumpLayoutData(char* aTitleStr,
}
//-------------------------------------------------------------
static void DumpPrintObjectsList(nsVoidArray * aDocList)
static void DumpPrintObjectsList(nsTArray<nsPrintObject*> * aDocList)
{
if (!kPrintingLogMod || kPrintingLogMod->level != DUMP_LAYOUT_LEVEL) return;
@ -3453,9 +3448,9 @@ static void DumpPrintObjectsList(nsVoidArray * aDocList)
const char types[][3] = {"DC", "FR", "IF", "FS"};
PR_PL(("Doc List\n***************************************************\n"));
PR_PL(("T P A H PO DocShell Seq Page Root Page# Rect\n"));
PRInt32 cnt = aDocList->Count();
PRInt32 cnt = aDocList->Length();
for (PRInt32 i=0;i<cnt;i++) {
nsPrintObject* po = (nsPrintObject*)aDocList->ElementAt(i);
nsPrintObject* po = aDocList->ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsIFrame* rootFrame = nsnull;
if (po->mPresShell) {
@ -3488,9 +3483,9 @@ static void DumpPrintObjectsTree(nsPrintObject * aPO, int aLevel, FILE* aFD)
fprintf(fd, "DocTree\n***************************************************\n");
fprintf(fd, "T PO DocShell Seq Page Page# Rect\n");
}
PRInt32 cnt = aPO->mKids.Count();
PRInt32 cnt = aPO->mKids.Length();
for (PRInt32 i=0;i<cnt;i++) {
nsPrintObject* po = (nsPrintObject*)aPO->mKids.ElementAt(i);
nsPrintObject* po = aPO->mKids.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
for (PRInt32 k=0;k<aLevel;k++) fprintf(fd, " ");
fprintf(fd, "%s %p %p %p %p %d %d,%d,%d,%d\n", types[po->mFrameType], po, po->mDocShell.get(), po->mSeqFrame,
@ -3561,9 +3556,9 @@ static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,
}
fprintf(fd, "<***************************************************>\n");
PRInt32 cnt = aPO->mKids.Count();
PRInt32 cnt = aPO->mKids.Length();
for (PRInt32 i=0;i<cnt;i++) {
nsPrintObject* po = (nsPrintObject*)aPO->mKids.ElementAt(i);
nsPrintObject* po = aPO->mKids.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
DumpPrintObjectsTreeLayout(po, aDC, aLevel+1, fd);
}
@ -3574,7 +3569,7 @@ static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,
}
//-------------------------------------------------------------
static void DumpPrintObjectsListStart(const char * aStr, nsVoidArray * aDocList)
static void DumpPrintObjectsListStart(const char * aStr, nsTArray<nsPrintObject*> * aDocList)
{
if (!kPrintingLogMod || kPrintingLogMod->level != DUMP_LAYOUT_LEVEL) return;

Просмотреть файл

@ -135,9 +135,9 @@ public:
PRBool DonePrintingPages(nsPrintObject* aPO, nsresult aResult);
//---------------------------------------------------------------------
void BuildDocTree(nsIDocShellTreeNode * aParentNode,
nsVoidArray * aDocList,
nsPrintObject * aPO);
void BuildDocTree(nsIDocShellTreeNode * aParentNode,
nsTArray<nsPrintObject*> * aDocList,
nsPrintObject * aPO);
nsresult ReflowDocList(nsPrintObject * aPO, PRBool aSetPixelScale);
nsresult ReflowPrintObject(nsPrintObject * aPO);

Просмотреть файл

@ -53,8 +53,8 @@ nsPrintObject::nsPrintObject() :
nsPrintObject::~nsPrintObject()
{
for (PRInt32 i=0;i<mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)mKids[i];
for (PRUint32 i=0;i<mKids.Length();i++) {
nsPrintObject* po = mKids[i];
delete po;
}

Просмотреть файл

@ -79,7 +79,7 @@ public:
nsIContent* mContent;
PrintObjectType mFrameType;
nsVoidArray mKids;
nsTArray<nsPrintObject*> mKids;
nsPrintObject* mParent;
PRPackedBool mHasBeenPrinted;
PRPackedBool mDontPrint;

Просмотреть файл

@ -1524,7 +1524,7 @@ CSSLoaderImpl::ParseSheet(nsIUnicharInputStream* aStream,
rv = parser->Parse(aStream, sheetURI, baseURI,
aLoadData->mSheet->Principal(), aLoadData->mLineNumber,
aLoadData->mAllowUnsafeRules);
mParsingDatas.RemoveElementAt(mParsingDatas.Count() - 1);
mParsingDatas.RemoveElementAt(mParsingDatas.Length() - 1);
RecycleParser(parser);
NS_ASSERTION(aLoadData->mPendingChildren == 0 || !aLoadData->mSyncLoad,
@ -1647,7 +1647,7 @@ CSSLoaderImpl::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
// or some such).
if (data->mParentData &&
--(data->mParentData->mPendingChildren) == 0 &&
mParsingDatas.IndexOf(data->mParentData) == -1) {
!mParsingDatas.Contains(data->mParentData)) {
DoSheetComplete(data->mParentData, aStatus, aDatasToNotify);
}
@ -1691,7 +1691,7 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,
{
LOG(("CSSLoaderImpl::LoadInlineStyle"));
NS_PRECONDITION(aStream, "Must have a stream to parse!");
NS_ASSERTION(mParsingDatas.Count() == 0, "We're in the middle of a parse?");
NS_ASSERTION(mParsingDatas.Length() == 0, "We're in the middle of a parse?");
*aCompleted = PR_TRUE;
@ -1761,7 +1761,7 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
{
LOG(("CSSLoaderImpl::LoadStyleLink"));
NS_PRECONDITION(aURL, "Must have URL to load");
NS_ASSERTION(mParsingDatas.Count() == 0, "We're in the middle of a parse?");
NS_ASSERTION(mParsingDatas.Length() == 0, "We're in the middle of a parse?");
LOG_URI(" Link uri: '%s'", aURL);
LOG((" Link title: '%s'", NS_ConvertUTF16toUTF8(aTitle).get()));
@ -1898,11 +1898,10 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
SheetLoadData* parentData = nsnull;
nsCOMPtr<nsICSSLoaderObserver> observer;
PRInt32 count = mParsingDatas.Count();
PRInt32 count = mParsingDatas.Length();
if (count > 0) {
LOG((" Have a parent load"));
parentData = static_cast<SheetLoadData*>
(mParsingDatas.ElementAt(count - 1));
parentData = mParsingDatas.ElementAt(count - 1);
// Check for cycles
SheetLoadData* data = parentData;
while (data && data->mURI) {
@ -2012,7 +2011,7 @@ CSSLoaderImpl::InternalLoadNonDocumentSheet(nsIURI* aURL,
{
NS_PRECONDITION(aURL, "Must have a URI to load");
NS_PRECONDITION(aSheet || aObserver, "Sheet and observer can't both be null");
NS_ASSERTION(mParsingDatas.Count() == 0, "We're in the middle of a parse?");
NS_ASSERTION(mParsingDatas.Length() == 0, "We're in the middle of a parse?");
LOG_URI(" Non-document sheet uri: '%s'", aURL);

Просмотреть файл

@ -492,7 +492,7 @@ private:
// We're not likely to have many levels of @import... But likely to have
// some. Allocate some storage, what the hell.
nsAutoVoidArray mParsingDatas;
nsAutoTArray<SheetLoadData*, 8> mParsingDatas;
// The array of posted stylesheet loaded events (SheetLoadDatas) we have.
// Note that these are rare.

Просмотреть файл

@ -63,7 +63,6 @@
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsIAtom.h"
#include "nsVoidArray.h"
#include "nsCOMArray.h"
#include "nsColor.h"
#include "nsStyleConsts.h"

Просмотреть файл

@ -65,7 +65,6 @@
#include "nsGkAtoms.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsVoidArray.h"
#include "nsDOMError.h"
#include "nsRuleWalker.h"
#include "nsCSSPseudoClasses.h"
@ -662,7 +661,7 @@ void RuleHash::EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData)
// Attribute selectors hash table.
struct AttributeSelectorEntry : public PLDHashEntryHdr {
nsIAtom *mAttribute;
nsVoidArray *mSelectors;
nsTArray<nsCSSSelector*> *mSelectors;
};
static void
@ -702,23 +701,23 @@ struct RuleCascadeData {
{
PL_DHashTableFinish(&mAttributeSelectors);
}
RuleHash mRuleHash;
nsVoidArray mStateSelectors;
nsVoidArray mClassSelectors;
nsVoidArray mIDSelectors;
PLDHashTable mAttributeSelectors; // nsIAtom* -> nsVoidArray*
RuleHash mRuleHash;
nsTArray<nsCSSSelector*> mStateSelectors;
nsTArray<nsCSSSelector*> mClassSelectors;
nsTArray<nsCSSSelector*> mIDSelectors;
PLDHashTable mAttributeSelectors;
nsTArray<nsFontFaceRuleContainer> mFontFaceRules;
// Looks up or creates the appropriate list in |mAttributeSelectors|.
// Returns null only on allocation failure.
nsVoidArray* AttributeListFor(nsIAtom* aAttribute);
nsTArray<nsCSSSelector*>* AttributeListFor(nsIAtom* aAttribute);
nsMediaQueryResultCacheKey mCacheKey;
RuleCascadeData* mNext; // for a different medium
};
nsVoidArray*
nsTArray<nsCSSSelector*>*
RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
{
AttributeSelectorEntry *entry = static_cast<AttributeSelectorEntry*>
@ -726,7 +725,7 @@ RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
if (!entry)
return nsnull;
if (!entry->mSelectors) {
if (!(entry->mSelectors = new nsVoidArray)) {
if (!(entry->mSelectors = new nsTArray<nsCSSSelector*>)) {
PL_DHashTableRawRemove(&mAttributeSelectors, entry);
return nsnull;
}
@ -1990,35 +1989,6 @@ IsSiblingOperator(PRUnichar oper)
return oper == PRUnichar('+') || oper == PRUnichar('~');
}
struct StateEnumData {
StateEnumData(StateRuleProcessorData *aData)
: data(aData), change(nsReStyleHint(0)) {}
StateRuleProcessorData *data;
nsReStyleHint change;
};
static PRBool StateEnumFunc(void* aSelector, void* aData)
{
StateEnumData *enumData = static_cast<StateEnumData*>(aData);
StateRuleProcessorData *data = enumData->data;
nsCSSSelector* selector = static_cast<nsCSSSelector*>(aSelector);
nsReStyleHint possibleChange = IsSiblingOperator(selector->mOperator) ?
eReStyle_LaterSiblings : eReStyle_Self;
// If enumData->change already includes all the bits of possibleChange, don't
// bother calling SelectorMatches, since even if it returns false
// enumData->change won't change.
if ((possibleChange & ~(enumData->change)) &&
SelectorMatches(*data, selector, data->mStateMask, nsnull, PR_TRUE) &&
SelectorMatchesTree(*data, selector->mNext, PR_TRUE)) {
enumData->change = nsReStyleHint(enumData->change | possibleChange);
}
return PR_TRUE;
}
NS_IMETHODIMP
nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult)
@ -2036,10 +2006,26 @@ nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData,
// "body > p:hover" will be in |cascade->mStateSelectors|). Note that
// |IsStateSelector| below determines which selectors are in
// |cascade->mStateSelectors|.
StateEnumData data(aData);
if (cascade)
cascade->mStateSelectors.EnumerateForwards(StateEnumFunc, &data);
*aResult = data.change;
if (cascade) {
*aResult = nsReStyleHint(0);
nsCSSSelector **iter = cascade->mStateSelectors.Elements(),
**end = iter + cascade->mStateSelectors.Length();
for(; iter != end; ++iter) {
nsCSSSelector* selector = *iter;
nsReStyleHint possibleChange = IsSiblingOperator(selector->mOperator) ?
eReStyle_LaterSiblings : eReStyle_Self;
// If *aResult already includes all the bits of possibleChange,
// don't bother calling SelectorMatches, since even if it returns false
// *aResult won't change.
if ((possibleChange & ~(*aResult)) &&
SelectorMatches(*aData, selector, aData->mStateMask, nsnull, PR_TRUE) &&
SelectorMatchesTree(*aData, selector->mNext, PR_TRUE)) {
*aResult = nsReStyleHint(*aResult | possibleChange);
}
}
}
return NS_OK;
}
@ -2052,26 +2038,23 @@ struct AttributeEnumData {
};
static PRBool AttributeEnumFunc(void* aSelector, void* aData)
static void
AttributeEnumFunc(nsCSSSelector* aSelector, AttributeEnumData* aData)
{
AttributeEnumData *enumData = static_cast<AttributeEnumData*>(aData);
AttributeRuleProcessorData *data = enumData->data;
nsCSSSelector* selector = static_cast<nsCSSSelector*>(aSelector);
AttributeRuleProcessorData *data = aData->data;
nsReStyleHint possibleChange = IsSiblingOperator(selector->mOperator) ?
nsReStyleHint possibleChange = IsSiblingOperator(aSelector->mOperator) ?
eReStyle_LaterSiblings : eReStyle_Self;
// If enumData->change already includes all the bits of possibleChange, don't
// bother calling SelectorMatches, since even if it returns false
// enumData->change won't change.
if ((possibleChange & ~(enumData->change)) &&
SelectorMatches(*data, selector, data->mStateMask, data->mAttribute,
if ((possibleChange & ~(aData->change)) &&
SelectorMatches(*data, aSelector, data->mStateMask, data->mAttribute,
PR_TRUE) &&
SelectorMatchesTree(*data, selector->mNext, PR_TRUE)) {
enumData->change = nsReStyleHint(enumData->change | possibleChange);
SelectorMatchesTree(*data, aSelector->mNext, PR_TRUE)) {
aData->change = nsReStyleHint(aData->change | possibleChange);
}
return PR_TRUE;
}
NS_IMETHODIMP
@ -2113,18 +2096,30 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
if (cascade) {
if (aData->mAttribute == aData->mContent->GetIDAttributeName()) {
cascade->mIDSelectors.EnumerateForwards(AttributeEnumFunc, &data);
nsCSSSelector **iter = cascade->mIDSelectors.Elements(),
**end = iter + cascade->mIDSelectors.Length();
for(; iter != end; ++iter) {
AttributeEnumFunc(*iter, &data);
}
}
if (aData->mAttribute == aData->mContent->GetClassAttributeName()) {
cascade->mClassSelectors.EnumerateForwards(AttributeEnumFunc, &data);
nsCSSSelector **iter = cascade->mClassSelectors.Elements(),
**end = iter + cascade->mClassSelectors.Length();
for(; iter != end; ++iter) {
AttributeEnumFunc(*iter, &data);
}
}
AttributeSelectorEntry *entry = static_cast<AttributeSelectorEntry*>
(PL_DHashTableOperate(&cascade->mAttributeSelectors, aData->mAttribute,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
entry->mSelectors->EnumerateForwards(AttributeEnumFunc, &data);
nsCSSSelector **iter = entry->mSelectors->Elements(),
**end = iter + entry->mSelectors->Length();
for(; iter != end; ++iter) {
AttributeEnumFunc(*iter, &data);
}
}
}
@ -2232,9 +2227,9 @@ AddRule(RuleValue* aRuleInfo, void* aCascade)
// Build the rule hash.
cascade->mRuleHash.PrependRule(aRuleInfo);
nsVoidArray* stateArray = &cascade->mStateSelectors;
nsVoidArray* classArray = &cascade->mClassSelectors;
nsVoidArray* idArray = &cascade->mIDSelectors;
nsTArray<nsCSSSelector*>* stateArray = &cascade->mStateSelectors;
nsTArray<nsCSSSelector*>* classArray = &cascade->mClassSelectors;
nsTArray<nsCSSSelector*>* idArray = &cascade->mIDSelectors;
for (nsCSSSelector* selector = aRuleInfo->mSelector;
selector; selector = selector->mNext) {
@ -2265,7 +2260,7 @@ AddRule(RuleValue* aRuleInfo, void* aCascade)
// Build mAttributeSelectors.
for (nsAttrSelector *attr = negation->mAttrList; attr;
attr = attr->mNext) {
nsVoidArray *array = cascade->AttributeListFor(attr->mAttr);
nsTArray<nsCSSSelector*> *array = cascade->AttributeListFor(attr->mAttr);
if (!array)
return PR_FALSE;
array->AppendElement(selector);

Просмотреть файл

@ -56,7 +56,7 @@
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIDOMStyleSheetList.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsIDOMCSSRule.h"
@ -895,16 +895,16 @@ nsCSSStyleSheetInner::AddSheet(nsICSSStyleSheet* aSheet)
void
nsCSSStyleSheetInner::RemoveSheet(nsICSSStyleSheet* aSheet)
{
if (1 == mSheets.Count()) {
NS_ASSERTION(aSheet == (nsICSSStyleSheet*)mSheets.ElementAt(0), "bad parent");
if (1 == mSheets.Length()) {
NS_ASSERTION(aSheet == mSheets.ElementAt(0), "bad parent");
delete this;
return;
}
if (aSheet == (nsICSSStyleSheet*)mSheets.ElementAt(0)) {
if (aSheet == mSheets.ElementAt(0)) {
mSheets.RemoveElementAt(0);
NS_ASSERTION(mSheets.Count(), "no parents");
NS_ASSERTION(mSheets.Length(), "no parents");
mOrderedRules.EnumerateForwards(SetStyleSheetReference,
(nsICSSStyleSheet*)mSheets.ElementAt(0));
mSheets.ElementAt(0));
}
else {
mSheets.RemoveElement(aSheet);
@ -1047,7 +1047,7 @@ nsCSSStyleSheet::~nsCSSStyleSheet()
// not be released. The document will let us know when it is going
// away.
if (mRuleProcessors) {
NS_ASSERTION(mRuleProcessors->Count() == 0, "destructing sheet with rule processor reference");
NS_ASSERTION(mRuleProcessors->Length() == 0, "destructing sheet with rule processor reference");
delete mRuleProcessors; // weak refs, should be empty here anyway
}
}
@ -1073,7 +1073,7 @@ NS_IMETHODIMP
nsCSSStyleSheet::AddRuleProcessor(nsCSSRuleProcessor* aProcessor)
{
if (! mRuleProcessors) {
mRuleProcessors = new nsAutoVoidArray();
mRuleProcessors = new nsAutoTArray<nsCSSRuleProcessor*, 8>();
if (!mRuleProcessors)
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1463,7 +1463,7 @@ nsCSSStyleSheet::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) cons
nsresult
nsCSSStyleSheet::EnsureUniqueInner()
{
if (1 < mInner->mSheets.Count()) {
if (1 < mInner->mSheets.Length()) {
nsCSSStyleSheetInner* clone = mInner->CloneFor(this);
if (clone) {
mInner->RemoveSheet(this);
@ -1549,20 +1549,15 @@ void nsCSSStyleSheet::List(FILE* out, PRInt32 aIndent) const
}
#endif
static PRBool
EnumClearRuleCascades(void* aProcessor, void* aData)
{
nsCSSRuleProcessor* processor =
static_cast<nsCSSRuleProcessor*>(aProcessor);
processor->ClearRuleCascades();
return PR_TRUE;
}
void
nsCSSStyleSheet::ClearRuleCascades()
{
if (mRuleProcessors) {
mRuleProcessors->EnumerateForwards(EnumClearRuleCascades, nsnull);
nsCSSRuleProcessor **iter = mRuleProcessors->Elements(),
**end = iter + mRuleProcessors->Length();
for(; iter != end; ++iter) {
(*iter)->ClearRuleCascades();
}
}
if (mParent) {
nsCSSStyleSheet* parent = (nsCSSStyleSheet*)mParent;

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsICSSStyleSheet.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsICSSLoaderObserver.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsCOMArray.h"
class nsIURI;
@ -78,7 +78,7 @@ public:
// Create a new namespace map
nsresult CreateNamespaceMap();
nsAutoVoidArray mSheets;
nsAutoTArray<nsICSSStyleSheet*, 8> mSheets;
nsCOMPtr<nsIURI> mSheetURI; // for error reports, etc.
nsCOMPtr<nsIURI> mOriginalSheetURI; // for GetHref. Can be null.
nsCOMPtr<nsIURI> mBaseURI; // for resolving relative URIs
@ -224,7 +224,7 @@ protected:
nsCSSStyleSheetInner* mInner;
nsAutoVoidArray* mRuleProcessors;
nsAutoTArray<nsCSSRuleProcessor*, 8>* mRuleProcessors;
friend class nsMediaList;
friend class nsCSSRuleProcessor;

Просмотреть файл

@ -73,6 +73,7 @@
#include "nsStyleTransformMatrix.h"
#include "nsCSSKeywords.h"
#include "nsCSSProps.h"
#include "nsTArray.h"
/*
* For storage of an |nsRuleNode|'s children in a PLDHashTable.
@ -2730,7 +2731,7 @@ nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
nsStyleFont* aFont)
{
// walk up the contexts until a context with the desired generic font
nsAutoVoidArray contextPath;
nsAutoTArray<nsStyleContext*, 8> contextPath;
contextPath.AppendElement(aContext);
nsStyleContext* higherContext = aContext->GetParent();
while (higherContext) {
@ -2758,8 +2759,8 @@ nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
PRBool dummy;
PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
for (PRInt32 i = contextPath.Count() - 1; i >= 0; --i) {
nsStyleContext* context = (nsStyleContext*)contextPath[i];
for (PRInt32 i = contextPath.Length() - 1; i >= 0; --i) {
nsStyleContext* context = contextPath[i];
nsRuleDataFont fontData; // Declare a struct with null CSS values.
nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Font), aPresContext, context);
ruleData.mFontData = &fontData;

Просмотреть файл

@ -51,7 +51,6 @@
#include "nsMargin.h"
#include "nsRect.h"
#include "nsFont.h"
#include "nsVoidArray.h"
#include "nsStyleCoord.h"
#include "nsStyleConsts.h"
#include "nsChangeHint.h"

Просмотреть файл

@ -173,7 +173,7 @@ NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsTreeContentView::GetRowCount(PRInt32* aRowCount)
{
*aRowCount = mRows.Count();
*aRowCount = mRows.Length();
return NS_OK;
}
@ -196,8 +196,8 @@ nsTreeContentView::SetSelection(nsITreeSelection* aSelection)
mUpdateSelection = PR_FALSE;
mSelection->SetSelectEventsSuppressed(PR_TRUE);
for (PRInt32 i = 0; i < mRows.Count(); ++i) {
Row* row = (Row*)mRows[i];
for (PRUint32 i = 0; i < mRows.Length(); ++i) {
Row* row = mRows[i];
nsCOMPtr<nsIDOMHTMLOptionElement> optEl = do_QueryInterface(row->mContent);
if (optEl) {
PRBool isSelected;
@ -215,11 +215,11 @@ NS_IMETHODIMP
nsTreeContentView::GetRowProperties(PRInt32 aIndex, nsISupportsArray* aProperties)
{
NS_ENSURE_ARG_POINTER(aProperties);
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
nsCOMPtr<nsIContent> realRow;
if (row->IsSeparator())
realRow = row->mContent;
@ -241,11 +241,11 @@ nsTreeContentView::GetCellProperties(PRInt32 aRow, nsITreeColumn* aCol, nsISuppo
{
NS_ENSURE_ARG_POINTER(aCol);
NS_ENSURE_ARG_POINTER(aProperties);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
if (realRow) {
@ -281,11 +281,11 @@ nsTreeContentView::GetColumnProperties(nsITreeColumn* aCol, nsISupportsArray* aP
NS_IMETHODIMP
nsTreeContentView::IsContainer(PRInt32 aIndex, PRBool* _retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = ((Row*)mRows[aIndex])->IsContainer();
*_retval = mRows[aIndex]->IsContainer();
return NS_OK;
}
@ -293,11 +293,11 @@ nsTreeContentView::IsContainer(PRInt32 aIndex, PRBool* _retval)
NS_IMETHODIMP
nsTreeContentView::IsContainerOpen(PRInt32 aIndex, PRBool* _retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = ((Row*)mRows[aIndex])->IsOpen();
*_retval = mRows[aIndex]->IsOpen();
return NS_OK;
}
@ -305,11 +305,11 @@ nsTreeContentView::IsContainerOpen(PRInt32 aIndex, PRBool* _retval)
NS_IMETHODIMP
nsTreeContentView::IsContainerEmpty(PRInt32 aIndex, PRBool* _retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = ((Row*)mRows[aIndex])->IsEmpty();
*_retval = mRows[aIndex]->IsEmpty();
return NS_OK;
}
@ -317,11 +317,11 @@ nsTreeContentView::IsContainerEmpty(PRInt32 aIndex, PRBool* _retval)
NS_IMETHODIMP
nsTreeContentView::IsSeparator(PRInt32 aIndex, PRBool *_retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = ((Row*)mRows[aIndex])->IsSeparator();
*_retval = mRows[aIndex]->IsSeparator();
return NS_OK;
}
@ -337,8 +337,8 @@ nsTreeContentView::IsSorted(PRBool *_retval)
NS_IMETHODIMP
nsTreeContentView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation, PRBool *_retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = PR_FALSE;
@ -349,8 +349,8 @@ nsTreeContentView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation, PRBool *_retval
NS_IMETHODIMP
nsTreeContentView::Drop(PRInt32 aRow, PRInt32 aOrientation)
{
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
return NS_OK;
@ -359,11 +359,12 @@ nsTreeContentView::Drop(PRInt32 aRow, PRInt32 aOrientation)
NS_IMETHODIMP
nsTreeContentView::GetParentIndex(PRInt32 aRowIndex, PRInt32* _retval)
{
NS_PRECONDITION(aRowIndex >= 0 && aRowIndex < mRows.Count(), "bad row index");
if (aRowIndex < 0 || aRowIndex >= mRows.Count())
NS_PRECONDITION(aRowIndex >= 0 && aRowIndex < PRInt32(mRows.Length()),
"bad row index");
if (aRowIndex < 0 || aRowIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = ((Row*)mRows[aRowIndex])->mParentIndex;
*_retval = mRows[aRowIndex]->mParentIndex;
return NS_OK;
}
@ -371,25 +372,26 @@ nsTreeContentView::GetParentIndex(PRInt32 aRowIndex, PRInt32* _retval)
NS_IMETHODIMP
nsTreeContentView::HasNextSibling(PRInt32 aRowIndex, PRInt32 aAfterIndex, PRBool* _retval)
{
NS_PRECONDITION(aRowIndex >= 0 && aRowIndex < mRows.Count(), "bad row index");
if (aRowIndex < 0 || aRowIndex >= mRows.Count())
NS_PRECONDITION(aRowIndex >= 0 && aRowIndex < PRInt32(mRows.Length()),
"bad row index");
if (aRowIndex < 0 || aRowIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
// We have a next sibling if the row is not the last in the subtree.
PRInt32 parentIndex = ((Row*)mRows[aRowIndex])->mParentIndex;
PRInt32 parentIndex = mRows[aRowIndex]->mParentIndex;
if (parentIndex >= 0) {
// Compute the last index in this subtree.
PRInt32 lastIndex = parentIndex + ((Row*)mRows[parentIndex])->mSubtreeSize;
Row* row = (Row*)mRows[lastIndex];
PRInt32 lastIndex = parentIndex + (mRows[parentIndex])->mSubtreeSize;
Row* row = mRows[lastIndex];
while (row->mParentIndex != parentIndex) {
lastIndex = row->mParentIndex;
row = (Row*)mRows[lastIndex];
row = mRows[lastIndex];
}
*_retval = aRowIndex < lastIndex;
}
else {
*_retval = aRowIndex < mRows.Count() - 1;
*_retval = PRUint32(aRowIndex) < mRows.Length() - 1;
}
return NS_OK;
@ -398,15 +400,15 @@ nsTreeContentView::HasNextSibling(PRInt32 aRowIndex, PRInt32 aAfterIndex, PRBool
NS_IMETHODIMP
nsTreeContentView::GetLevel(PRInt32 aIndex, PRInt32* _retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
PRInt32 level = 0;
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
while (row->mParentIndex >= 0) {
level++;
row = (Row*)mRows[row->mParentIndex];
row = mRows[row->mParentIndex];
}
*_retval = level;
@ -418,11 +420,11 @@ nsTreeContentView::GetImageSrc(PRInt32 aRow, nsITreeColumn* aCol, nsAString& _re
{
_retval.Truncate();
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -439,13 +441,13 @@ NS_IMETHODIMP
nsTreeContentView::GetProgressMode(PRInt32 aRow, nsITreeColumn* aCol, PRInt32* _retval)
{
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = nsITreeView::PROGRESS_NONE;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -470,11 +472,11 @@ nsTreeContentView::GetCellValue(PRInt32 aRow, nsITreeColumn* aCol, nsAString& _r
{
_retval.Truncate();
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -492,13 +494,13 @@ nsTreeContentView::GetCellText(PRInt32 aRow, nsITreeColumn* aCol, nsAString& _re
{
_retval.Truncate();
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
NS_PRECONDITION(aCol, "bad column");
if (aRow < 0 || aRow >= mRows.Count() || !aCol)
if (aRow < 0 || aRow >= PRInt32(mRows.Length()) || !aCol)
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
// Check for a "label" attribute - this is valid on an <treeitem>
// or an <option>, with a single implied column.
@ -570,13 +572,13 @@ nsTreeContentView::SetTree(nsITreeBoxObject* aTree)
NS_IMETHODIMP
nsTreeContentView::ToggleOpenState(PRInt32 aIndex)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
// We don't serialize content right here, since content might be generated
// lazily.
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
if (row->mContent->Tag() == nsGkAtoms::optgroup &&
row->mContent->IsNodeOfType(nsINode::eHTML)) {
@ -650,13 +652,13 @@ nsTreeContentView::IsEditable(PRInt32 aRow, nsITreeColumn* aCol, PRBool* _retval
{
*_retval = PR_FALSE;
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = PR_TRUE;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -674,13 +676,13 @@ nsTreeContentView::IsEditable(PRInt32 aRow, nsITreeColumn* aCol, PRBool* _retval
NS_IMETHODIMP
nsTreeContentView::IsSelectable(PRInt32 aRow, nsITreeColumn* aCol, PRBool* _retval)
{
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
*_retval = PR_TRUE;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -699,11 +701,11 @@ NS_IMETHODIMP
nsTreeContentView::SetCellValue(PRInt32 aRow, nsITreeColumn* aCol, const nsAString& aValue)
{
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -720,11 +722,11 @@ NS_IMETHODIMP
nsTreeContentView::SetCellText(PRInt32 aRow, nsITreeColumn* aCol, const nsAString& aValue)
{
NS_ENSURE_ARG_POINTER(aCol);
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
if (aRow < 0 || aRow >= mRows.Count())
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aRow];
Row* row = mRows[aRow];
nsCOMPtr<nsIContent> realRow;
nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow, getter_AddRefs(realRow));
@ -759,11 +761,11 @@ nsTreeContentView::PerformActionOnCell(const PRUnichar* aAction, PRInt32 aRow, n
NS_IMETHODIMP
nsTreeContentView::GetItemAtIndex(PRInt32 aIndex, nsIDOMElement** _retval)
{
NS_PRECONDITION(aIndex >= 0 && aIndex < mRows.Count(), "bad index");
if (aIndex < 0 || aIndex >= mRows.Count())
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
return NS_ERROR_INVALID_ARG;
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
row->mContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)_retval);
return NS_OK;
@ -880,7 +882,7 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument,
else if (tag == nsGkAtoms::treeitem) {
PRInt32 index = FindContent(aContent);
if (index >= 0) {
Row* row = (Row*)mRows[index];
Row* row = mRows[index];
if (aAttribute == nsGkAtoms::container) {
PRBool isContainer =
aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container,
@ -1007,7 +1009,7 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
if (childTag == nsGkAtoms::treechildren) {
PRInt32 index = FindContent(aContainer);
if (index >= 0) {
Row* row = (Row*)mRows[index];
Row* row = mRows[index];
row->SetEmpty(PR_FALSE);
if (mBoxObject)
mBoxObject->InvalidateRow(index);
@ -1090,7 +1092,7 @@ nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
if (tag == nsGkAtoms::treechildren) {
PRInt32 index = FindContent(aContainer);
if (index >= 0) {
Row* row = (Row*)mRows[index];
Row* row = mRows[index];
row->SetEmpty(PR_TRUE);
PRInt32 count = RemoveSubtree(index);
// Invalidate also the row to update twisty.
@ -1136,13 +1138,14 @@ nsTreeContentView::NodeWillBeDestroyed(const nsINode* aNode)
// Recursively serialize content, starting with aContent.
void
nsTreeContentView::Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows)
nsTreeContentView::Serialize(nsIContent* aContent, PRInt32 aParentIndex,
PRInt32* aIndex, nsTArray<Row*>& aRows)
{
ChildIterator iter, last;
for (ChildIterator::Init(aContent, &iter, &last); iter != last; ++iter) {
nsCOMPtr<nsIContent> content = *iter;
nsIAtom *tag = content->Tag();
PRInt32 count = aRows.Count();
PRInt32 count = aRows.Length();
if (content->IsNodeOfType(nsINode::eXUL)) {
if (tag == nsGkAtoms::treeitem)
@ -1156,12 +1159,13 @@ nsTreeContentView::Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRInt32
else if (tag == nsGkAtoms::optgroup)
SerializeOptGroup(content, aParentIndex, aIndex, aRows);
}
*aIndex += aRows.Count() - count;
*aIndex += aRows.Length() - count;
}
}
void
nsTreeContentView::SerializeItem(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows)
nsTreeContentView::SerializeItem(nsIContent* aContent, PRInt32 aParentIndex,
PRInt32* aIndex, nsTArray<Row*>& aRows)
{
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
nsGkAtoms::_true, eCaseMatters))
@ -1180,10 +1184,10 @@ nsTreeContentView::SerializeItem(nsIContent* aContent, PRInt32 aParentIndex, PRI
nsTreeUtils::GetImmediateChild(aContent, nsGkAtoms::treechildren, getter_AddRefs(child));
if (child) {
// Now, recursively serialize our child.
PRInt32 count = aRows.Count();
PRInt32 count = aRows.Length();
PRInt32 index = 0;
Serialize(child, aParentIndex + *aIndex + 1, &index, aRows);
row->mSubtreeSize += aRows.Count() - count;
row->mSubtreeSize += aRows.Length() - count;
}
else
row->SetEmpty(PR_TRUE);
@ -1195,7 +1199,9 @@ nsTreeContentView::SerializeItem(nsIContent* aContent, PRInt32 aParentIndex, PRI
}
void
nsTreeContentView::SerializeSeparator(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows)
nsTreeContentView::SerializeSeparator(nsIContent* aContent,
PRInt32 aParentIndex, PRInt32* aIndex,
nsTArray<Row*>& aRows)
{
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
nsGkAtoms::_true, eCaseMatters))
@ -1208,7 +1214,7 @@ nsTreeContentView::SerializeSeparator(nsIContent* aContent, PRInt32 aParentIndex
void
nsTreeContentView::SerializeOption(nsIContent* aContent, PRInt32 aParentIndex,
PRInt32* aIndex, nsVoidArray& aRows)
PRInt32* aIndex, nsTArray<Row*>& aRows)
{
Row* row = Row::Create(mAllocator, aContent, aParentIndex);
aRows.AppendElement(row);
@ -1225,7 +1231,7 @@ nsTreeContentView::SerializeOption(nsIContent* aContent, PRInt32 aParentIndex,
void
nsTreeContentView::SerializeOptGroup(nsIContent* aContent, PRInt32 aParentIndex,
PRInt32* aIndex, nsVoidArray& aRows)
PRInt32* aIndex, nsTArray<Row*>& aRows)
{
Row* row = Row::Create(mAllocator, aContent, aParentIndex);
aRows.AppendElement(row);
@ -1236,10 +1242,10 @@ nsTreeContentView::SerializeOptGroup(nsIContent* aContent, PRInt32 aParentIndex,
nsTreeUtils::GetImmediateChild(aContent, nsGkAtoms::option, getter_AddRefs(child));
if (child) {
// Now, recursively serialize our child.
PRInt32 count = aRows.Count();
PRInt32 count = aRows.Length();
PRInt32 index = 0;
Serialize(aContent, aParentIndex + *aIndex + 1, &index, aRows);
row->mSubtreeSize += aRows.Count() - count;
row->mSubtreeSize += aRows.Length() - count;
}
else
row->SetEmpty(PR_TRUE);
@ -1295,7 +1301,7 @@ nsTreeContentView::GetIndexInSubtree(nsIContent* aContainer,
PRInt32
nsTreeContentView::EnsureSubtree(PRInt32 aIndex)
{
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
nsCOMPtr<nsIContent> child;
if (row->mContent->Tag() == nsGkAtoms::optgroup)
@ -1307,11 +1313,11 @@ nsTreeContentView::EnsureSubtree(PRInt32 aIndex)
}
}
nsAutoVoidArray rows;
nsAutoTArray<Row*, 8> rows;
PRInt32 index = 0;
Serialize(child, aIndex, &index, rows);
mRows.InsertElementsAt(rows, aIndex + 1);
PRInt32 count = rows.Count();
mRows.InsertElementsAt(aIndex + 1, rows);
PRInt32 count = rows.Length();
row->mSubtreeSize += count;
UpdateSubtreeSizes(row->mParentIndex, count);
@ -1326,11 +1332,11 @@ nsTreeContentView::EnsureSubtree(PRInt32 aIndex)
PRInt32
nsTreeContentView::RemoveSubtree(PRInt32 aIndex)
{
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
PRInt32 count = row->mSubtreeSize;
for(PRInt32 i = 0; i < count; i++) {
Row* nextRow = (Row*)mRows[aIndex + i + 1];
Row* nextRow = mRows[aIndex + i + 1];
Row::Destroy(mAllocator, nextRow);
}
mRows.RemoveElementsAt(aIndex + 1, count);
@ -1366,7 +1372,7 @@ nsTreeContentView::InsertRowFor(nsIContent* aParent, nsIContent* aChild)
grandParentIndex = FindContent(grandParent);
if (grandParentIndex >= 0) {
// Got it, now test if it is open.
if (((Row*)mRows[grandParentIndex])->IsOpen())
if (mRows[grandParentIndex]->IsOpen())
insertRow = PR_TRUE;
}
}
@ -1384,7 +1390,7 @@ nsTreeContentView::InsertRowFor(nsIContent* aParent, nsIContent* aChild)
PRInt32
nsTreeContentView::InsertRow(PRInt32 aParentIndex, PRInt32 aIndex, nsIContent* aContent)
{
nsAutoVoidArray rows;
nsAutoTArray<Row*, 8> rows;
nsIAtom *tag = aContent->Tag();
if (aContent->IsNodeOfType(nsINode::eXUL)) {
if (tag == nsGkAtoms::treeitem)
@ -1399,8 +1405,8 @@ nsTreeContentView::InsertRow(PRInt32 aParentIndex, PRInt32 aIndex, nsIContent* a
SerializeOptGroup(aContent, aParentIndex, &aIndex, rows);
}
mRows.InsertElementsAt(rows, aParentIndex + aIndex + 1);
PRInt32 count = rows.Count();
mRows.InsertElementsAt(aParentIndex + aIndex + 1, rows);
PRInt32 count = rows.Length();
UpdateSubtreeSizes(aParentIndex, count);
@ -1414,13 +1420,13 @@ nsTreeContentView::InsertRow(PRInt32 aParentIndex, PRInt32 aIndex, nsIContent* a
PRInt32
nsTreeContentView::RemoveRow(PRInt32 aIndex)
{
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
PRInt32 count = row->mSubtreeSize + 1;
PRInt32 parentIndex = row->mParentIndex;
Row::Destroy(mAllocator, row);
for(PRInt32 i = 1; i < count; i++) {
Row* nextRow = (Row*)mRows[aIndex + i];
Row* nextRow = mRows[aIndex + i];
Row::Destroy(mAllocator, nextRow);
}
mRows.RemoveElementsAt(aIndex, count);
@ -1435,8 +1441,8 @@ nsTreeContentView::RemoveRow(PRInt32 aIndex)
void
nsTreeContentView::ClearRows()
{
for (PRInt32 i = 0; i < mRows.Count(); i++)
Row::Destroy(mAllocator, (Row*)mRows[i]);
for (PRUint32 i = 0; i < mRows.Length(); i++)
Row::Destroy(mAllocator, mRows[i]);
mRows.Clear();
mRoot = nsnull;
mBody = nsnull;
@ -1450,7 +1456,7 @@ nsTreeContentView::ClearRows()
void
nsTreeContentView::OpenContainer(PRInt32 aIndex)
{
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
row->SetOpen(PR_TRUE);
PRInt32 count = EnsureSubtree(aIndex);
@ -1463,7 +1469,7 @@ nsTreeContentView::OpenContainer(PRInt32 aIndex)
void
nsTreeContentView::CloseContainer(PRInt32 aIndex)
{
Row* row = (Row*)mRows[aIndex];
Row* row = mRows[aIndex];
row->SetOpen(PR_FALSE);
PRInt32 count = RemoveSubtree(aIndex);
@ -1476,8 +1482,8 @@ nsTreeContentView::CloseContainer(PRInt32 aIndex)
PRInt32
nsTreeContentView::FindContent(nsIContent* aContent)
{
for (PRInt32 i = 0; i < mRows.Count(); i++) {
if (((Row*)mRows[i])->mContent == aContent) {
for (PRUint32 i = 0; i < mRows.Length(); i++) {
if (mRows[i]->mContent == aContent) {
return i;
}
}
@ -1489,7 +1495,7 @@ void
nsTreeContentView::UpdateSubtreeSizes(PRInt32 aParentIndex, PRInt32 count)
{
while (aParentIndex >= 0) {
Row* row = (Row*)mRows[aParentIndex];
Row* row = mRows[aParentIndex];
row->mSubtreeSize += count;
aParentIndex = row->mParentIndex;
}
@ -1498,9 +1504,9 @@ nsTreeContentView::UpdateSubtreeSizes(PRInt32 aParentIndex, PRInt32 count)
void
nsTreeContentView::UpdateParentIndexes(PRInt32 aIndex, PRInt32 aSkip, PRInt32 aCount)
{
PRInt32 count = mRows.Count();
PRInt32 count = mRows.Length();
for (PRInt32 i = aIndex + aSkip; i < count; i++) {
Row* row = (Row*)mRows[i];
Row* row = mRows[i];
if (row->mParentIndex > aIndex) {
row->mParentIndex += aCount;
}

Просмотреть файл

@ -39,7 +39,7 @@
#define nsTreeContentView_h__
#include "nsFixedSizeAllocator.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIDocument.h"
#include "nsStubDocumentObserver.h"
#include "nsITreeBoxObject.h"
@ -48,6 +48,8 @@
#include "nsITreeContentView.h"
#include "nsITreeSelection.h"
class Row;
nsresult NS_NewTreeContentView(nsITreeView** aResult);
class nsTreeContentView : public nsINativeTreeView,
@ -80,17 +82,20 @@ class nsTreeContentView : public nsINativeTreeView,
protected:
// Recursive methods which deal with serializing of nested content.
void Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void Serialize(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex,
nsTArray<Row*>& aRows);
void SerializeItem(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void SerializeItem(nsIContent* aContent, PRInt32 aParentIndex,
PRInt32* aIndex, nsTArray<Row*>& aRows);
void SerializeSeparator(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex, nsVoidArray& aRows);
void SerializeSeparator(nsIContent* aContent, PRInt32 aParentIndex,
PRInt32* aIndex, nsTArray<Row*>& aRows);
void SerializeOption(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex,
nsVoidArray& aRows);
nsTArray<Row*>& aRows);
void SerializeOptGroup(nsIContent* aContent, PRInt32 aParentIndex, PRInt32* aIndex,
nsVoidArray& aRows);
nsTArray<Row*>& aRows);
void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, PRInt32* aResult);
@ -127,7 +132,7 @@ class nsTreeContentView : public nsINativeTreeView,
nsCOMPtr<nsIContent> mBody;
nsIDocument* mDocument; // WEAK
nsFixedSizeAllocator mAllocator;
nsVoidArray mRows;
nsTArray<Row*> mRows;
PRPackedBool mUpdateSelection;
};