From 49cb03082eeac722bb4c4410b109fd3850a2ad9d Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Thu, 8 Jan 2015 22:26:01 +0100 Subject: [PATCH] Slightly Improved Size Calculation of MPExpressionLayout. --- MathKit/MPExpressionLayout.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/MathKit/MPExpressionLayout.m b/MathKit/MPExpressionLayout.m index 0905031..a28e17e 100644 --- a/MathKit/MPExpressionLayout.m +++ b/MathKit/MPExpressionLayout.m @@ -129,14 +129,13 @@ if (self.expression.countElements == 0) { return NSMakeRect(0, kMPEmptyBoxYOrigin, kMPEmptyBoxWidth, kMPEmptyBoxHeight); } - CGFloat x = 0, y = 0, width = 0, height = 0; + CGRect bounds = NSMakeRect(0, 0, 0, 0); for (NSUInteger index = 0; index < self.expression.countElements; index++) { NSRect elementBounds = [self boundsOfElementAtIndex:index]; - width += elementBounds.size.width; - height = MAX(height, elementBounds.size.height); - y = MIN(y, elementBounds.origin.y); + elementBounds.origin.x = bounds.size.width; + bounds = NSUnionRect(bounds, elementBounds); } - return NSMakeRect(x, y, width, height); + return bounds; }