Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 526394. Part 23: Make nsRect::IntersectRect preserve height and w…
Browse files Browse the repository at this point in the history
…idth if possible even when the intersection of two rectangles is empty. r=mats
  • Loading branch information
rocallahan committed Jan 11, 2010
1 parent ad6416e commit 15669f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 7 additions & 7 deletions gfx/src/nsRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ PRBool nsRect::IntersectRect(const nsRect &aRect1, const nsRect &aRect2)
// Compute the destination width
temp = PR_MIN(xmost1, xmost2);
if (temp <= x) {
Empty();
return PR_FALSE;
width = 0;
} else {
width = temp - x;
}
width = temp - x;

// Compute the destination height
temp = PR_MIN(ymost1, ymost2);
if (temp <= y) {
Empty();
return PR_FALSE;
height = 0;
} else {
height = temp - y;
}
height = temp - y;

return PR_TRUE;
return !IsEmpty();
}

// Computes the smallest rectangle that contains both aRect1 and aRect2 and
Expand Down
4 changes: 3 additions & 1 deletion layout/base/nsCSSRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,9 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext,
// up by drawing tiles into temporary surfaces and copying those to the
// destination, but after pixel-snapping tiles may not all be the same size.
nsRect dirty;
dirty.IntersectRect(aDirtyRect, aFillArea);
if (!dirty.IntersectRect(aDirtyRect, aFillArea))
return;

gfxRect areaToFill = RectToGfxRect(aFillArea, appUnitsPerPixel);
gfxMatrix ctm = ctx->CurrentMatrix();

Expand Down
2 changes: 1 addition & 1 deletion layout/xul/base/src/nsMenuPopupFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,8 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)

// ensure that anchorRect is on screen
if (!anchorRect.IntersectRect(anchorRect, screenRect)) {
anchorRect.width = anchorRect.height = 0;
// if the anchor isn't within the screen, move it to the edge of the screen.
// IntersectRect will have set both the width and height of anchorRect to 0.
if (anchorRect.x < screenRect.x)
anchorRect.x = screenRect.x;
if (anchorRect.XMost() > screenRect.XMost())
Expand Down

0 comments on commit 15669f3

Please sign in to comment.