зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1126164 - Avoid setting clip regions on plugin windows if the same clip region was already set. r=roc
This commit is contained in:
Родитель
86c2c22675
Коммит
7c8119a5cf
|
@ -4227,9 +4227,11 @@ nsWindow::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
|
|||
}
|
||||
}
|
||||
|
||||
if (!StoreWindowClipRegion(*newRects))
|
||||
if (IsWindowClipRegionEqual(*newRects))
|
||||
return NS_OK;
|
||||
|
||||
StoreWindowClipRegion(*newRects);
|
||||
|
||||
if (!mGdkWindow)
|
||||
return NS_OK;
|
||||
|
||||
|
|
|
@ -647,18 +647,21 @@ nsTransparencyMode nsBaseWidget::GetTransparencyMode() {
|
|||
}
|
||||
|
||||
bool
|
||||
nsBaseWidget::IsWindowClipRegionEqual(const nsTArray<nsIntRect>& aRects)
|
||||
{
|
||||
return mClipRects &&
|
||||
mClipRectCount == aRects.Length() &&
|
||||
memcmp(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsBaseWidget::StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects)
|
||||
{
|
||||
if (mClipRects && mClipRectCount == aRects.Length() &&
|
||||
memcmp(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0)
|
||||
return false;
|
||||
|
||||
mClipRectCount = aRects.Length();
|
||||
mClipRects = new nsIntRect[mClipRectCount];
|
||||
if (mClipRects) {
|
||||
memcpy(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -695,16 +698,8 @@ nsBaseWidget::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
|
|||
bool aIntersectWithExisting)
|
||||
{
|
||||
if (!aIntersectWithExisting) {
|
||||
nsBaseWidget::StoreWindowClipRegion(aRects);
|
||||
StoreWindowClipRegion(aRects);
|
||||
} else {
|
||||
// In this case still early return if nothing changed.
|
||||
if (mClipRects && mClipRectCount == aRects.Length() &&
|
||||
memcmp(mClipRects,
|
||||
aRects.Elements(),
|
||||
sizeof(nsIntRect)*mClipRectCount) == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// get current rects
|
||||
nsTArray<nsIntRect> currentRects;
|
||||
GetWindowClipRegion(¤tRects);
|
||||
|
@ -719,7 +714,7 @@ nsBaseWidget::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
|
|||
nsTArray<nsIntRect> rects;
|
||||
ArrayFromRegion(intersection, rects);
|
||||
// store
|
||||
nsBaseWidget::StoreWindowClipRegion(rects);
|
||||
StoreWindowClipRegion(rects);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -362,9 +362,12 @@ protected:
|
|||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
protected:
|
||||
// Stores the clip rectangles in aRects into mClipRects. Returns true
|
||||
// if the new rectangles are different from the old rectangles.
|
||||
bool StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects);
|
||||
// Utility to check if an array of clip rects is equal to our
|
||||
// internally stored clip rect array mClipRects.
|
||||
bool IsWindowClipRegionEqual(const nsTArray<nsIntRect>& aRects);
|
||||
|
||||
// Stores the clip rectangles in aRects into mClipRects.
|
||||
void StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects);
|
||||
|
||||
virtual already_AddRefed<nsIWidget>
|
||||
AllocateChildPopupWidget()
|
||||
|
|
|
@ -6440,6 +6440,10 @@ nsresult
|
|||
nsWindow::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
|
||||
bool aIntersectWithExisting)
|
||||
{
|
||||
if (IsWindowClipRegionEqual(aRects)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsBaseWidget::SetWindowClipRegion(aRects, aIntersectWithExisting);
|
||||
|
||||
HRGN dest = CreateHRGNFromArray(aRects);
|
||||
|
|
Загрузка…
Ссылка в новой задаче