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.
This commit is contained in:
Aparajita Fishman committed 2013-07-14 15:59:23 -04:00
1 parent e8b2f2e39f
commit fbc869ad29
1 file changed
+7 -2
+7 -2
View File
@@ -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];