зеркало из https://github.com/mozilla/gecko-dev.git
Bug 94243: VoidArray usage patch. a=asa sr=brendan r=waterson r=bienvenu
r=pierre r=jband/dbradley Also fixes some whitespace issues.
This commit is contained in:
Родитель
df60e7bfb0
Коммит
6f3e4115eb
|
@ -1148,7 +1148,7 @@ CSSDeclarationImpl::CSSDeclarationImpl(const CSSDeclarationImpl& aCopy)
|
|||
}
|
||||
|
||||
if (aCopy.mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
if (mOrder) {
|
||||
(*mOrder) = *(aCopy.mOrder);
|
||||
}
|
||||
|
@ -1853,13 +1853,16 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
if (eCSSUnit_Null != aValue.GetUnit()) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
|
@ -1934,13 +1937,16 @@ CSSDeclarationImpl::AppendStructValue(nsCSSProperty aProperty, void* aStruct)
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)(PRInt32)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
}
|
||||
|
@ -3439,7 +3445,7 @@ CSSDeclarationImpl::AppendComment(const nsAReadableString& aComment)
|
|||
nsresult result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull == mComments) {
|
||||
mComments = new nsStringArray();
|
||||
|
|
|
@ -1148,7 +1148,7 @@ CSSDeclarationImpl::CSSDeclarationImpl(const CSSDeclarationImpl& aCopy)
|
|||
}
|
||||
|
||||
if (aCopy.mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
if (mOrder) {
|
||||
(*mOrder) = *(aCopy.mOrder);
|
||||
}
|
||||
|
@ -1853,13 +1853,16 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
if (eCSSUnit_Null != aValue.GetUnit()) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
|
@ -1934,13 +1937,16 @@ CSSDeclarationImpl::AppendStructValue(nsCSSProperty aProperty, void* aStruct)
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)(PRInt32)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
}
|
||||
|
@ -3439,7 +3445,7 @@ CSSDeclarationImpl::AppendComment(const nsAReadableString& aComment)
|
|||
nsresult result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull == mComments) {
|
||||
mComments = new nsStringArray();
|
||||
|
|
|
@ -97,9 +97,11 @@ struct nsFontStyle;
|
|||
struct nsFontWeight;
|
||||
struct nsFontLangGroup;
|
||||
|
||||
class nsFontNodeArray : public nsVoidArray
|
||||
class nsFontNodeArray : public nsAutoVoidArray
|
||||
{
|
||||
public:
|
||||
nsFontNodeArray() {};
|
||||
|
||||
nsFontNode* GetElement(PRInt32 aIndex)
|
||||
{
|
||||
return (nsFontNode*) ElementAt(aIndex);
|
||||
|
@ -934,6 +936,11 @@ InitGlobals(void)
|
|||
}
|
||||
|
||||
nsFontMetricsGTK::nsFontMetricsGTK()
|
||||
: mFonts() // I'm not sure what the common size is here - I generally
|
||||
// see 2-5 entries. For now, punt and let it be allocated later. We can't
|
||||
// make it an nsAutoVoidArray since it's a cString array.
|
||||
// XXX mFontIsGeneric will generally need to be the same size; right now
|
||||
// it's an nsAutoVoidArray. If the average is under 8, that's ok.
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gFontMetricsGTKCount++;
|
||||
|
@ -1084,19 +1091,19 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
getter_AddRefs(charset));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = gCharSetManager->GetUnicodeEncoder(charset,
|
||||
&gUserDefinedConverter);
|
||||
&gUserDefinedConverter);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = gUserDefinedConverter->SetOutputErrorBehavior(
|
||||
gUserDefinedConverter->kOnError_Replace, nsnull, '?');
|
||||
gUserDefinedConverter->kOnError_Replace, nsnull, '?');
|
||||
nsCOMPtr<nsICharRepresentable> mapper =
|
||||
do_QueryInterface(gUserDefinedConverter);
|
||||
do_QueryInterface(gUserDefinedConverter);
|
||||
if (mapper) {
|
||||
res = mapper->FillInfo(gUserDefinedMap);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return res;
|
||||
|
@ -1570,13 +1577,13 @@ DoubleByteConvert(nsFontCharSetInfo* aSelf, XFontStruct* aFont,
|
|||
if (count > 0) {
|
||||
if ((aDestBuf[0] & 0x80) && (!(aFont->max_byte1 & 0x80))) {
|
||||
for (PRInt32 i = 0; i < aDestLen; i++) {
|
||||
aDestBuf[i] &= 0x7F;
|
||||
}
|
||||
aDestBuf[i] &= 0x7F;
|
||||
}
|
||||
}
|
||||
else if ((!(aDestBuf[0] & 0x80)) && (aFont->min_byte1 & 0x80)) {
|
||||
for (PRInt32 i = 0; i < aDestLen; i++) {
|
||||
aDestBuf[i] |= 0x80;
|
||||
}
|
||||
aDestBuf[i] |= 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2516,7 +2523,7 @@ nsFontMetricsGTK::PickASizeAndLoad(nsFontStretch* aStretch,
|
|||
}
|
||||
font->mSize = scale_size;
|
||||
font->mCharSetInfo = aCharSet;
|
||||
aStretch->mScaledFonts.AppendElement(font);
|
||||
aStretch->mScaledFonts.AppendElement(font);
|
||||
}
|
||||
else {
|
||||
return nsnull;
|
||||
|
@ -3123,12 +3130,7 @@ GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
|
|||
found = 1;
|
||||
}
|
||||
else {
|
||||
PRInt32 n = aNodes->Count();
|
||||
for (PRInt32 j = 0; j < n; j++) {
|
||||
if (aNodes->GetElement(j) == node) {
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
found = (aNodes->IndexOf(node) >= 0);
|
||||
}
|
||||
previousNodeName = nodeName;
|
||||
if (!found) {
|
||||
|
@ -3281,7 +3283,9 @@ static nsresult
|
|||
GetAllFontNames(void)
|
||||
{
|
||||
if (!gGlobalList) {
|
||||
gGlobalList = new nsFontNodeArray();
|
||||
// This may well expand further (families * sizes * styles?), but it's
|
||||
// only created once.
|
||||
gGlobalList = new nsFontNodeArray;
|
||||
if (!gGlobalList) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -3419,6 +3423,9 @@ nsFontMetricsGTK::TryNode(nsCString* aName, PRUnichar aChar)
|
|||
GetFontNames(pattern.get(), &nodes);
|
||||
// no need to call gNodes->Put() since GetFontNames already did
|
||||
if (nodes.Count() > 0) {
|
||||
// XXX This assertion may be spurious; you can have more than
|
||||
// -*-courier-iso8859-1 font, for example, from different
|
||||
// foundries.
|
||||
NS_ASSERTION((nodes.Count() == 1), "unexpected number of nodes");
|
||||
node = nodes.GetElement(0);
|
||||
}
|
||||
|
@ -3545,6 +3552,8 @@ nsFontMetricsGTK::FindStyleSheetSpecificFont(PRUnichar aChar)
|
|||
|
||||
/*
|
||||
* count hyphens
|
||||
* XXX It might be good to try to pre-cache this information instead
|
||||
* XXX of recalculating it on every font access!
|
||||
*/
|
||||
const char* str = familyName->get();
|
||||
FIND_FONT_PRINTF((" familyName = %s", str));
|
||||
|
@ -3824,7 +3833,7 @@ nsFontMetricsGTK::FindSubstituteFont(PRUnichar aChar)
|
|||
if (!mSubstituteFont) {
|
||||
for (int i = 0; i < mLoadedFontsCount; i++) {
|
||||
if (FONT_HAS_GLYPH(mLoadedFonts[i]->mMap, 'a')) {
|
||||
mSubstituteFont = new nsFontGTKSubstitute(mLoadedFonts[i]);
|
||||
mSubstituteFont = new nsFontGTKSubstitute(mLoadedFonts[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
|
||||
nsCStringArray mFonts;
|
||||
PRUint16 mFontsIndex;
|
||||
nsVoidArray mFontIsGeneric;
|
||||
nsAutoVoidArray mFontIsGeneric;
|
||||
|
||||
nsCAutoString mDefaultFont;
|
||||
nsCString *mGeneric;
|
||||
|
|
|
@ -615,10 +615,7 @@ nsFontCache :: GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
if (aLangGroup == langGroup.get()) {
|
||||
if (cnt != 0) {
|
||||
// promote it to the front of the cache
|
||||
for (PRInt32 i = cnt; i > 0; --i)
|
||||
mFontMetrics.ReplaceElementAt(mFontMetrics[i - 1], i);
|
||||
|
||||
mFontMetrics.ReplaceElementAt(metrics, 0);
|
||||
mFontMetrics.MoveElement(0, cnt);
|
||||
}
|
||||
NS_ADDREF(aMetrics = metrics);
|
||||
return NS_OK;
|
||||
|
|
|
@ -1548,8 +1548,12 @@ nsresult nsObserverTopic::Notify(eHTMLTags aTag,nsIParserNode& aNode,void* aUniq
|
|||
PRInt32 theAttrCount =aNode.GetAttributeCount();
|
||||
PRInt32 theObserversCount=theObservers->GetSize();
|
||||
if(0<theObserversCount){
|
||||
nsStringArray keys,values;
|
||||
nsStringArray keys(theAttrCount+4),values(theAttrCount+4);
|
||||
|
||||
// XXX this and the following code may be a performance issue.
|
||||
// Every key and value is copied and added to an voidarray (causing at
|
||||
// least 2 allocations for mImpl, usually more, plus at least 1 per
|
||||
// string (total = 2*(keys+3) + 2(or more) array allocations )).
|
||||
PRInt32 index;
|
||||
for(index=0; index<theAttrCount; index++) {
|
||||
keys.AppendString(aNode.GetKeyAt(index));
|
||||
|
@ -1643,6 +1647,7 @@ CObserverService::~CObserverService() {
|
|||
}
|
||||
}
|
||||
|
||||
// XXX This may be more efficient as a HashTable instead of linear search
|
||||
nsObserverTopic* CObserverService::GetTopic(const nsString& aTopic) {
|
||||
PRInt32 theIndex=0;
|
||||
nsObserverTopic *theTopic=(nsObserverTopic*)mTopics.ObjectAt(theIndex++);
|
||||
|
|
|
@ -930,6 +930,13 @@ XPCJSRuntime::DeferredRelease(nsISupports* obj)
|
|||
XPCLock* lock = GetMainThreadOnlyGC() ? nsnull : GetMapLock();
|
||||
{
|
||||
XPCAutoLock al(lock); // lock if necessary
|
||||
if(!mNativesToReleaseArray.Count())
|
||||
{
|
||||
// This array sometimes has 1000's
|
||||
// of entries, and usually has 50-200 entries. Avoid lots
|
||||
// of incremental grows. We compact it down when we're done.
|
||||
mNativesToReleaseArray.SizeTo(256);
|
||||
}
|
||||
return mNativesToReleaseArray.AppendElement(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -536,7 +536,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext,
|
|||
mVisualFrames.Clear();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
mVisualFrames.ReplaceElementAt(mLogicalFrames[mIndexMap[i]], i);
|
||||
mVisualFrames.AppendElement(mLogicalFrames[mIndexMap[i]]);
|
||||
if (i != mIndexMap[i]) {
|
||||
aBidiEnabled = PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -536,7 +536,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext,
|
|||
mVisualFrames.Clear();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
mVisualFrames.ReplaceElementAt(mLogicalFrames[mIndexMap[i]], i);
|
||||
mVisualFrames.AppendElement(mLogicalFrames[mIndexMap[i]]);
|
||||
if (i != mIndexMap[i]) {
|
||||
aBidiEnabled = PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -515,8 +515,8 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
GetView(aPresContext, &view);
|
||||
|
||||
if (view) {
|
||||
nsIViewManager *vm;
|
||||
view->GetViewManager(vm);
|
||||
nsCOMPtr<nsIViewManager> vm;
|
||||
view->GetViewManager(*getter_AddRefs(vm));
|
||||
const nsStyleDisplay* display;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||
|
||||
|
@ -537,10 +537,10 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// Make sure visibility is correct
|
||||
vm->SetViewVisibility(view, viewIsVisible ? nsViewVisibility_kShow :
|
||||
nsViewVisibility_kHide);
|
||||
if (vm)
|
||||
vm->SetViewVisibility(view, viewIsVisible ? nsViewVisibility_kShow :
|
||||
nsViewVisibility_kHide);
|
||||
|
||||
NS_RELEASE(vm);
|
||||
}
|
||||
NS_ASSERTION(aDesiredSize.width < 100000, "Width is still NS_UNCONSTRAINEDSIZE");
|
||||
NS_ASSERTION(aDesiredSize.height < 100000, "Height is still NS_UNCONSTRAINEDSIZE");
|
||||
|
@ -2567,7 +2567,7 @@ nsGfxListControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpd
|
|||
mSelectionCache->Clear();
|
||||
for (PRInt32 i = 0; i < length; i++) {
|
||||
selected = IsContentSelectedByIndex(i);
|
||||
mSelectionCache->InsertElementAt((void*)selected, i);
|
||||
mSelectionCache->AppendElement((void*)selected);
|
||||
changed = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -2803,6 +2803,9 @@ nsGfxListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext)
|
|||
parent->GetView(aPresContext, &parentView);
|
||||
|
||||
parentView->GetViewManager(*getter_AddRefs(viewManager));
|
||||
if (!viewManager)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GetViewOffset(viewManager, parentView, parentPos);
|
||||
nsIView* view = nsnull;
|
||||
GetView(aPresContext, &view);
|
||||
|
|
|
@ -1148,7 +1148,7 @@ CSSDeclarationImpl::CSSDeclarationImpl(const CSSDeclarationImpl& aCopy)
|
|||
}
|
||||
|
||||
if (aCopy.mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
if (mOrder) {
|
||||
(*mOrder) = *(aCopy.mOrder);
|
||||
}
|
||||
|
@ -1853,13 +1853,16 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
if (eCSSUnit_Null != aValue.GetUnit()) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
|
@ -1934,13 +1937,16 @@ CSSDeclarationImpl::AppendStructValue(nsCSSProperty aProperty, void* aStruct)
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)(PRInt32)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
}
|
||||
|
@ -3439,7 +3445,7 @@ CSSDeclarationImpl::AppendComment(const nsAReadableString& aComment)
|
|||
nsresult result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull == mComments) {
|
||||
mComments = new nsStringArray();
|
||||
|
|
|
@ -1148,7 +1148,7 @@ CSSDeclarationImpl::CSSDeclarationImpl(const CSSDeclarationImpl& aCopy)
|
|||
}
|
||||
|
||||
if (aCopy.mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
if (mOrder) {
|
||||
(*mOrder) = *(aCopy.mOrder);
|
||||
}
|
||||
|
@ -1853,13 +1853,16 @@ CSSDeclarationImpl::AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValu
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
if (eCSSUnit_Null != aValue.GetUnit()) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
|
@ -1934,13 +1937,16 @@ CSSDeclarationImpl::AppendStructValue(nsCSSProperty aProperty, void* aStruct)
|
|||
|
||||
if (NS_OK == result) {
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
else {
|
||||
// order IS important for CSS, so remove and add to the end
|
||||
PRInt32 index = mOrder->IndexOf((void*)(PRInt32)aProperty);
|
||||
if (-1 != index) {
|
||||
mOrder->RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
if (nsnull != mOrder) {
|
||||
mOrder->AppendElement((void*)(PRInt32)aProperty);
|
||||
}
|
||||
}
|
||||
|
@ -3439,7 +3445,7 @@ CSSDeclarationImpl::AppendComment(const nsAReadableString& aComment)
|
|||
nsresult result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (nsnull == mOrder) {
|
||||
mOrder = new nsVoidArray();
|
||||
mOrder = new nsAutoVoidArray();
|
||||
}
|
||||
if (nsnull == mComments) {
|
||||
mComments = new nsStringArray();
|
||||
|
|
|
@ -839,11 +839,6 @@ nsresult nsMsgFilterList::MoveFilterAt(PRUint32 filterIndex,
|
|||
|
||||
NS_ENSURE_ARG(filterCount >= filterIndex);
|
||||
|
||||
nsCOMPtr<nsIMsgFilter> tempFilter;
|
||||
rv = m_filters->GetElementAt(filterIndex, getter_AddRefs(tempFilter));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgFilter> oldElement;
|
||||
PRUint32 newIndex = filterIndex;
|
||||
|
||||
if (motion == nsMsgFilterMotion::up)
|
||||
|
@ -860,12 +855,7 @@ nsresult nsMsgFilterList::MoveFilterAt(PRUint32 filterIndex,
|
|||
// are we already at the bottom?
|
||||
if (newIndex > filterCount - 1) return NS_OK;
|
||||
}
|
||||
|
||||
m_filters->GetElementAt(newIndex, getter_AddRefs(oldElement));
|
||||
m_filters->ReplaceElementAt(NS_STATIC_CAST(nsISupports*,oldElement),
|
||||
filterIndex);
|
||||
m_filters->ReplaceElementAt(NS_STATIC_CAST(nsISupports*,tempFilter),
|
||||
newIndex);
|
||||
m_filters->MoveElement(filterIndex,newIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1548,8 +1548,12 @@ nsresult nsObserverTopic::Notify(eHTMLTags aTag,nsIParserNode& aNode,void* aUniq
|
|||
PRInt32 theAttrCount =aNode.GetAttributeCount();
|
||||
PRInt32 theObserversCount=theObservers->GetSize();
|
||||
if(0<theObserversCount){
|
||||
nsStringArray keys,values;
|
||||
nsStringArray keys(theAttrCount+4),values(theAttrCount+4);
|
||||
|
||||
// XXX this and the following code may be a performance issue.
|
||||
// Every key and value is copied and added to an voidarray (causing at
|
||||
// least 2 allocations for mImpl, usually more, plus at least 1 per
|
||||
// string (total = 2*(keys+3) + 2(or more) array allocations )).
|
||||
PRInt32 index;
|
||||
for(index=0; index<theAttrCount; index++) {
|
||||
keys.AppendString(aNode.GetKeyAt(index));
|
||||
|
@ -1643,6 +1647,7 @@ CObserverService::~CObserverService() {
|
|||
}
|
||||
}
|
||||
|
||||
// XXX This may be more efficient as a HashTable instead of linear search
|
||||
nsObserverTopic* CObserverService::GetTopic(const nsString& aTopic) {
|
||||
PRInt32 theIndex=0;
|
||||
nsObserverTopic *theTopic=(nsObserverTopic*)mTopics.ObjectAt(theIndex++);
|
||||
|
|
|
@ -353,9 +353,9 @@ protected:
|
|||
}
|
||||
if (nsnull != mParent)
|
||||
{
|
||||
nsIViewManager* vm = nsnull;
|
||||
mParent->GetViewManager(vm);
|
||||
if (nsnull != vm)
|
||||
nsCOMPtr<nsIViewManager> vm;
|
||||
mParent->GetViewManager(*getter_AddRefs(vm));
|
||||
if (vm)
|
||||
{
|
||||
vm->RemoveChild(mParent, this);
|
||||
}
|
||||
|
@ -986,6 +986,8 @@ static void ApplyZOrderStableSort(nsVoidArray &aBuffer, nsVoidArray &aMergeTmp,
|
|||
DisplayListElement2* e2 = NS_STATIC_CAST(DisplayListElement2*, aBuffer.ElementAt(j + 1));
|
||||
if (e1->mZIndex > e2->mZIndex) {
|
||||
sorted = PR_FALSE;
|
||||
// We could use aBuffer.MoveElement(), but it wouldn't be much of
|
||||
// a win if any for swapping two elements.
|
||||
aBuffer.ReplaceElementAt(e2, j);
|
||||
aBuffer.ReplaceElementAt(e1, j + 1);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,18 @@
|
|||
*/
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* Parameters:
|
||||
* 1. the array to sort
|
||||
* 2. the number of elements in the array
|
||||
* 3. the size of the array
|
||||
* 4. comparison function taking two elements and parameter #5 and
|
||||
* returning an integer:
|
||||
* + less than zero if the first element should be before the second
|
||||
* + 0 if the order of the elements does not matter
|
||||
* + greater than zero if the second element should be before the first
|
||||
* 5. extra data to pass to comparison function
|
||||
*/
|
||||
PR_EXTERN(void) NS_QuickSort(void *, unsigned int, unsigned int,
|
||||
int (*)(const void *, const void *, void *),
|
||||
void *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -299,24 +299,20 @@ nsSHEntry::AddChild(nsISHEntry * aChild, PRInt32 aOffset)
|
|||
|
||||
NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
|
||||
PRInt32 childCount = mChildren.Count();
|
||||
if (aOffset < childCount)
|
||||
mChildren.ReplaceElementAt((void *) aChild, aOffset);
|
||||
else
|
||||
{
|
||||
//
|
||||
// Bug 52670: Ensure children are added in order.
|
||||
//
|
||||
// Later frames in the child list may load faster and get appended
|
||||
// before earlier frames, causing session history to be scrambled.
|
||||
// By growing the list here, they are added to the right position.
|
||||
//
|
||||
// Assert that aOffset will not be so high as to grow us a lot.
|
||||
//
|
||||
NS_ASSERTION(aOffset < (childCount + 1023), "Large frames array!\n");
|
||||
while (aOffset > childCount++)
|
||||
mChildren.AppendElement(nsnull);
|
||||
mChildren.AppendElement((void *)aChild);
|
||||
}
|
||||
//
|
||||
// Bug 52670: Ensure children are added in order.
|
||||
//
|
||||
// Later frames in the child list may load faster and get appended
|
||||
// before earlier frames, causing session history to be scrambled.
|
||||
// By growing the list here, they are added to the right position.
|
||||
//
|
||||
// Assert that aOffset will not be so high as to grow us a lot.
|
||||
//
|
||||
NS_ASSERTION(aOffset < (childCount + 1023), "Large frames array!\n");
|
||||
|
||||
// This implicitly extends the array to include aOffset
|
||||
mChildren.ReplaceElementAt(aChild, aOffset);
|
||||
|
||||
NS_ADDREF(aChild);
|
||||
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче