bug 787704, better to remember addref/release sContent in IMEStateManager, r=masayuki
--- a/content/events/src/nsIMEStateManager.cpp
+++ b/content/events/src/nsIMEStateManager.cpp
@@ -56,17 +56,17 @@ nsIMEStateManager::OnDestroyPresContext(
return NS_OK;
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
if (widget) {
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
SetIMEState(newState, nullptr, widget, action);
}
- sContent = nullptr;
+ NS_IF_RELEASE(sContent);
sPresContext = nullptr;
OnTextStateBlur(nullptr, nullptr);
return NS_OK;
}
nsresult
nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
nsIContent* aContent)
@@ -84,17 +84,17 @@ nsIMEStateManager::OnRemoveContent(nsPre
if (NS_FAILED(rv))
widget->ResetInputState();
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
SetIMEState(newState, nullptr, widget, action);
}
- sContent = nullptr;
+ NS_IF_RELEASE(sContent);
sPresContext = nullptr;
return NS_OK;
}
nsresult
nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
nsIContent* aContent,
@@ -167,17 +167,20 @@ nsIMEStateManager::OnChangeFocusInternal
if (oldWidget)
oldWidget->ResetInputState();
}
// Update IME state for new focus widget
SetIMEState(newState, aContent, widget, aAction);
sPresContext = aPresContext;
- sContent = aContent;
+ if (sContent != aContent) {
+ NS_IF_RELEASE(sContent);
+ NS_IF_ADDREF(sContent = aContent);
+ }
return NS_OK;
}
void
nsIMEStateManager::OnInstalledMenuKeyboardListener(bool aInstalling)
{
sInstalledMenuKeyboardListener = aInstalling;