From fbc869ad29abe50975cefc0d1abab56902774b4a Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Sun, 14 Jul 2013 15:59:07 -0400 Subject: [PATCH] Fixed: in certain degenerate cases, CPTextField may not have a window within _isWithinUsablePlatformRect Previously, a case could arise where a text field was set as the initial first responder but during cib loading was not yet assigned to a window. In this case _isWithinUsablePlatformRect would fail. Now _isWithinUsablePlatformRect checks to make sure the text field has a window. --- AppKit/CPTextField.j | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 5f89813f0..695e96acb 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1605,8 +1605,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); // Make sure the text field is completely within the platform window // so the browser will not scroll it into view. - var wind = [self window], - frame = [self convertRectToBase:[self bounds]], + var wind = [self window]; + + // If the field is not yet within a window, it can't be first responder + if (!wind) + return NO; + + var frame = [self convertRectToBase:[self bounds]], usableRect = [[wind platformWindow] usableContentFrame]; frame.origin = [wind convertBaseToGlobal:frame.origin];