Wow, the Chrome debugger is much better than Safari. Anyway, I found the following.
The code in question is this, reformatted for clarity:
containerSize = CPPlatform.isa.objj_msgSend0(CPPlatform, "isBrowser") ?
This method call returns a true value, so the next is executed:
((___r1 = self._platformWindow),
Chrome says that the _platformWindow property of self (a CPPanel) is null. Therefore the following:
___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "contentBounds")).size
is trying to get the “size” property of “null”, rather explicitly. This must be a compiler side-effect to allow for method calls on null objects but fails when using objects in place of Foundation structs. The original code comes from this:
containerSize = [CPPlatform isBrowser] ? [_platformWindow contentBounds].size : [[self screen] visibleFrame].size;
So the question now is, why is _platformWindow sometimes null? What I have figured so far (at least in Chrome) is that if the browser window isn’t frontmost then [CPApp keyWindow] returns null, which CPAlert uses to determine the platform window. I would prefer to still be able to pop up the message when the browser is in the background, in case it would be seen by the user.
So I added this:
if (![CPApp keyWindow])
{
[_sessionAlert _createWindowWithStyle:_CPModalWindowMask];
[[_sessionAlert window] setPlatformWindow:[theWindow platformWindow]];
}
Which works, but is it unwise?
>
> On Mar 10, 2016, at 12:12 PM, Martin Carlberg <
mar...@oops.se> wrote:
>
> I use Chrome to debug Cappuccino code. Open the dev tools in Chrome and navigate to the CPWindow.j file with the cmd/ctrl- o command from the source tab. After you have found the CPWindow.j file find the ’center’ method with crtl/cmd-shift-o.