mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 630919, add collect and invalidate phases for tree ranges, r=enn+neil, a=jst
--HG-- extra : rebase_source : 0a714e7f3829f9641340e47a83f386ab7a0d0905
This commit is contained in:
parent
5166267748
commit
56d4d954cb
@ -212,18 +212,40 @@ struct nsTreeRange
|
||||
return total;
|
||||
}
|
||||
|
||||
static void CollectRanges(nsTreeRange* aRange, nsTArray<PRInt32>& aRanges)
|
||||
{
|
||||
nsTreeRange* cur = aRange;
|
||||
while (cur) {
|
||||
aRanges.AppendElement(cur->mMin);
|
||||
aRanges.AppendElement(cur->mMax);
|
||||
cur = cur->mNext;
|
||||
}
|
||||
}
|
||||
|
||||
static void InvalidateRanges(nsITreeBoxObject* aTree,
|
||||
nsTArray<PRInt32>& aRanges)
|
||||
{
|
||||
if (aTree) {
|
||||
nsCOMPtr<nsITreeBoxObject> tree = aTree;
|
||||
for (PRUint32 i = 0; i < aRanges.Length(); i += 2) {
|
||||
aTree->InvalidateRange(aRanges[i], aRanges[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Invalidate() {
|
||||
if (mSelection->mTree)
|
||||
mSelection->mTree->InvalidateRange(mMin, mMax);
|
||||
if (mNext)
|
||||
mNext->Invalidate();
|
||||
nsTArray<PRInt32> ranges;
|
||||
CollectRanges(this, ranges);
|
||||
InvalidateRanges(mSelection->mTree, ranges);
|
||||
|
||||
}
|
||||
|
||||
void RemoveAllBut(PRInt32 aIndex) {
|
||||
if (aIndex >= mMin && aIndex <= mMax) {
|
||||
|
||||
// Invalidate everything in this list.
|
||||
mSelection->mFirstRange->Invalidate();
|
||||
nsTArray<PRInt32> ranges;
|
||||
CollectRanges(mSelection->mFirstRange, ranges);
|
||||
|
||||
mMin = aIndex;
|
||||
mMax = aIndex;
|
||||
@ -239,6 +261,7 @@ struct nsTreeRange
|
||||
delete mSelection->mFirstRange;
|
||||
mSelection->mFirstRange = this;
|
||||
}
|
||||
InvalidateRanges(mSelection->mTree, ranges);
|
||||
}
|
||||
else if (mNext)
|
||||
mNext->RemoveAllBut(aIndex);
|
||||
@ -453,6 +476,7 @@ NS_IMETHODIMP nsTreeSelection::RangedSelect(PRInt32 aStartIndex, PRInt32 aEndInd
|
||||
if (mFirstRange) {
|
||||
mFirstRange->Invalidate();
|
||||
delete mFirstRange;
|
||||
mFirstRange = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user