From 4cd08635088361b0ce96053a6a747260b02bd19a Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Wed, 21 Mar 2007 01:32:01 +0000 Subject: [PATCH] Bug 374652 - return appropriate rect for gfxRect::Union if one of the sources is empty. r=vlad git-svn-id: svn://10.0.0.236/trunk@222133 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/thebes/src/gfxRect.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mozilla/gfx/thebes/src/gfxRect.cpp b/mozilla/gfx/thebes/src/gfxRect.cpp index c8a694def9f..7895baaae5f 100644 --- a/mozilla/gfx/thebes/src/gfxRect.cpp +++ b/mozilla/gfx/thebes/src/gfxRect.cpp @@ -57,13 +57,14 @@ gfxRect gfxRect::Intersect(const gfxRect& aRect) const gfxRect gfxRect::Union(const gfxRect& aRect) const { - gfxRect result(0,0,0,0); - if (!aRect.IsEmpty() && !IsEmpty()) { - gfxFloat x = PR_MIN(aRect.X(), X()); - gfxFloat xmost = PR_MAX(aRect.XMost(), XMost()); - gfxFloat y = PR_MIN(aRect.Y(), Y()); - gfxFloat ymost = PR_MAX(aRect.YMost(), YMost()); - result = gfxRect(x, y, xmost - x, ymost - y); - } - return result; + if (IsEmpty()) + return aRect; + if (aRect.IsEmpty()) + return *this; + + gfxFloat x = PR_MIN(aRect.X(), X()); + gfxFloat xmost = PR_MAX(aRect.XMost(), XMost()); + gfxFloat y = PR_MIN(aRect.Y(), Y()); + gfxFloat ymost = PR_MAX(aRect.YMost(), YMost()); + return gfxRect(x, y, xmost - x, ymost - y); }