Bug 1051842 - Part 1 - [e10s] crash in -[ChildView keyDown:]. r=smichaud

Fix Cocoa window IME focus test to work even if window has not received
OSX main-window status.
This commit is contained in:
David Parks 2015-01-12 08:26:05 -08:00
parent 9a85475001
commit d72e351c3e
3 changed files with 23 additions and 1 deletions

View File

@ -830,8 +830,17 @@ public:
void SetIMEOpenState(bool aOpen);
void SetASCIICapableOnly(bool aASCIICapableOnly);
/**
* True if OSX believes that our view has keyboard focus.
*/
bool IsFocused();
/**
* True if our view has keyboard focus (and our window is key), or if
* it would have keyboard focus if our window were key.
*/
bool IsOrWouldBeFocused();
static CFArrayRef CreateAllIMEModeList();
static void DebugPrintAllIMEModes();

View File

@ -3491,6 +3491,19 @@ IMEInputHandler::IsFocused()
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
}
bool
IMEInputHandler::IsOrWouldBeFocused()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
NS_ENSURE_TRUE(!Destroyed(), false);
NSWindow* window = [mView window];
NS_ENSURE_TRUE(window, false);
return [window firstResponder] == mView;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
}
bool
IMEInputHandler::IsIMEOpened()
{

View File

@ -1623,7 +1623,7 @@ nsChildView::SetInputContext(const InputContext& aContext,
{
NS_ENSURE_TRUE_VOID(mTextInputHandler);
if (mTextInputHandler->IsFocused()) {
if (mTextInputHandler->IsOrWouldBeFocused()) {
if (aContext.IsPasswordEditor()) {
TextInputHandler::EnableSecureEventInput();
} else {