Bug 590568. Make sure that that stored window clip rects always match what we set on the window even if intersecting with the existing region. r=roc a=blocking

This commit is contained in:
Timothy Nikkel 2010-12-31 14:16:35 -06:00
parent d40e3ea557
commit 537293e375
2 changed files with 37 additions and 6 deletions

View File

@ -7081,6 +7081,27 @@ CreateHRGNFromArray(const nsTArray<nsIntRect>& aRects)
return ::ExtCreateRegion(NULL, buf.Length(), data);
}
static const nsIntRegion
RegionFromArray(const nsTArray<nsIntRect>& aRects)
{
nsIntRegion region;
for (PRUint32 i = 0; i < aRects.Length(); ++i) {
region.Or(region, aRects[i]);
}
return region;
}
static const nsTArray<nsIntRect>
ArrayFromRegion(const nsIntRegion& aRegion)
{
nsTArray<nsIntRect> rects;
const nsIntRect* r;
for (nsIntRegionRectIterator iter(aRegion); (r = iter.Next());) {
rects.AppendElement(*r);
}
return rects;
}
nsresult
nsWindow::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
PRBool aIntersectWithExisting)
@ -7096,6 +7117,22 @@ nsWindow::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
sizeof(nsIntRect)*mClipRectCount) == 0) {
return NS_OK;
}
// get current rects
nsTArray<nsIntRect> currentRects;
GetWindowClipRegion(&currentRects);
// create region from them
nsIntRegion currentRegion = RegionFromArray(currentRects);
// create region from new rects
nsIntRegion newRegion = RegionFromArray(aRects);
// intersect regions
nsIntRegion intersection;
intersection.And(currentRegion, newRegion);
// create int rect array from intersection
nsTArray<nsIntRect> rects = ArrayFromRegion(intersection);
// store
if (!StoreWindowClipRegion(rects))
return NS_OK;
}
HRGN dest = CreateHRGNFromArray(aRects);

View File

@ -460,12 +460,6 @@ protected:
void StopFlashing();
static PRBool IsTopLevelMouseExit(HWND aWnd);
static void SetupKeyModifiersSequence(nsTArray<KeyPair>* aArray, PRUint32 aModifiers);
/*
* If aIntersectWithExisting is true then the stored clip region isn't
* updated (only the actual clip on the window) so this should be called
* again soon afterward with aIntersectWithExisting false so the stored clip
* region does get updated.
*/
nsresult SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
PRBool aIntersectWithExisting);
nsIntRegion GetRegionToPaint(PRBool aForceFullRepaint,