From 7b14f41cd8ab3be93efceacfe9014b646c7b8484 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Mon, 26 Oct 2009 22:43:51 -0700 Subject: [PATCH] Added CGRectNull support to CGRectUnion. Reviewed by me. --- AppKit/CoreGraphics/CGGeometry.j | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AppKit/CoreGraphics/CGGeometry.j b/AppKit/CoreGraphics/CGGeometry.j index a046638fe..3c2902ddb 100644 --- a/AppKit/CoreGraphics/CGGeometry.j +++ b/AppKit/CoreGraphics/CGGeometry.j @@ -70,6 +70,8 @@ _function(CGInsetMakeZero()) _function(CGInsetMakeCopy(anInset)) _function(CGInsetIsEmpty(anInset)) +CGRectNull = _CGRectMake(Infinity, Infinity, 0.0, 0.0); + /*! @addtogroup appkit @{ @@ -174,6 +176,15 @@ function CGRectStandardize(aRect) function CGRectUnion(lhsRect, rhsRect) { + var lhsRectIsNull = !lhsRect || lhsRect === CGRectNull, + rhsRectIsNull = !rhsRect || rhsRect === CGRectNull; + + if (lhsRectIsNull) + return rhsRectIsNull ? CGRectNull : rhsRect; + + if (rhsRectIsNull) + return lhsRectIsNull ? CGRectNull : lhsRect; + var minX = MIN(_CGRectGetMinX(lhsRect), _CGRectGetMinX(rhsRect)), minY = MIN(_CGRectGetMinY(lhsRect), _CGRectGetMinY(rhsRect)), maxX = MAX(_CGRectGetMaxX(lhsRect), _CGRectGetMaxX(rhsRect)),