--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -342,17 +342,17 @@ IMEStateManager::OnDestroyPresContext(ns
DestroyIMEContentObserver();
if (sWidget) {
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
InputContext::Origin origin =
sActiveTabParent ? InputContext::ORIGIN_CONTENT : sOrigin;
- SetIMEState(newState, nullptr, sWidget, action, origin);
+ SetIMEState(newState, nullptr, nullptr, sWidget, action, origin);
}
sWidget = nullptr;
sContent = nullptr;
sPresContext = nullptr;
sActiveTabParent = nullptr;
return NS_OK;
}
@@ -399,17 +399,17 @@ IMEStateManager::OnRemoveContent(nsPresC
// Current IME transaction should commit
if (sWidget) {
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
InputContext::Origin origin =
sActiveTabParent ? InputContext::ORIGIN_CONTENT : sOrigin;
- SetIMEState(newState, nullptr, sWidget, action, origin);
+ SetIMEState(newState, aPresContext, nullptr, sWidget, action, origin);
}
sWidget = nullptr;
sContent = nullptr;
sPresContext = nullptr;
sActiveTabParent = nullptr;
return NS_OK;
@@ -629,17 +629,17 @@ IMEStateManager::OnChangeFocusInternal(n
// focus.
bool gotFocus = aContent || (newState.mEnabled == IMEState::ENABLED);
aAction.mFocusChange =
gotFocus ? InputContextAction::GOT_FOCUS :
InputContextAction::LOST_FOCUS;
}
// Update IME state for new focus widget
- SetIMEState(newState, aContent, newWidget, aAction,
+ SetIMEState(newState, aPresContext, aContent, newWidget, aAction,
newTabParent ? InputContext::ORIGIN_CONTENT : sOrigin);
}
sActiveTabParent = newTabParent;
sPresContext = aPresContext;
sContent = aContent;
// Don't call CreateIMEContentObserver() here except when a plugin gets
@@ -781,17 +781,17 @@ IMEStateManager::OnClickInEditor(nsPresC
}
InputContextAction::Cause cause =
aMouseEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH ?
InputContextAction::CAUSE_TOUCH : InputContextAction::CAUSE_MOUSE;
InputContextAction action(cause, InputContextAction::FOCUS_NOT_CHANGED);
IMEState newState = GetNewIMEState(aPresContext, aContent);
- SetIMEState(newState, aContent, widget, action, sOrigin);
+ SetIMEState(newState, aPresContext, aContent, widget, action, sOrigin);
}
// static
void
IMEStateManager::OnFocusInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
EditorBase& aEditorBase)
{
@@ -990,17 +990,17 @@ IMEStateManager::UpdateIMEState(const IM
if (createTextStateManager) {
DestroyIMEContentObserver();
}
if (updateIMEState) {
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::FOCUS_NOT_CHANGED);
- SetIMEState(aNewIMEState, aContent, widget, action, sOrigin);
+ SetIMEState(aNewIMEState, presContext, aContent, widget, action, sOrigin);
if (NS_WARN_IF(widget->Destroyed())) {
MOZ_LOG(sISMLog, LogLevel::Error,
(" UpdateIMEState(), widget has gone during setting input context"));
return;
}
}
if (createTextStateManager) {
@@ -1100,25 +1100,26 @@ void
IMEStateManager::SetInputContextForChildProcess(
TabParent* aTabParent,
const InputContext& aInputContext,
const InputContextAction& aAction)
{
MOZ_LOG(sISMLog, LogLevel::Info,
("SetInputContextForChildProcess(aTabParent=0x%p, "
"aInputContext={ mIMEState={ mEnabled=%s, mOpen=%s }, "
- "mHTMLInputType=\"%s\", mHTMLInputInputmode=\"%s\", mActionHint=\"%s\" }, "
- "aAction={ mCause=%s, mAction=%s }), "
+ "mHTMLInputType=\"%s\", mHTMLInputInputmode=\"%s\", mActionHint=\"%s\", "
+ "mInPrivateBrowsing=%s }, aAction={ mCause=%s, mAction=%s }), "
"sPresContext=0x%p (available: %s), sWidget=0x%p (available: %s), "
"sActiveTabParent=0x%p",
aTabParent, GetIMEStateEnabledName(aInputContext.mIMEState.mEnabled),
GetIMEStateSetOpenName(aInputContext.mIMEState.mOpen),
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputType).get(),
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputInputmode).get(),
NS_ConvertUTF16toUTF8(aInputContext.mActionHint).get(),
+ GetBoolName(aInputContext.mInPrivateBrowsing),
GetActionCauseName(aAction.mCause),
GetActionFocusChangeName(aAction.mFocusChange),
sPresContext.get(), GetBoolName(CanHandleWith(sPresContext)),
sWidget, GetBoolName(sWidget && !sWidget->Destroyed()),
sActiveTabParent.get()));
if (aTabParent != sActiveTabParent) {
MOZ_LOG(sISMLog, LogLevel::Error,
@@ -1148,16 +1149,17 @@ IMEStateManager::SetInputContextForChild
MOZ_ASSERT(aInputContext.mOrigin == InputContext::ORIGIN_CONTENT);
SetInputContext(widget, aInputContext, aAction);
}
// static
void
IMEStateManager::SetIMEState(const IMEState& aState,
+ nsPresContext* aPresContext,
nsIContent* aContent,
nsIWidget* aWidget,
InputContextAction aAction,
InputContext::Origin aOrigin)
{
MOZ_LOG(sISMLog, LogLevel::Info,
("SetIMEState(aState={ mEnabled=%s, mOpen=%s }, "
"aContent=0x%p (TabParent=0x%p), aWidget=0x%p, aAction={ mCause=%s, "
@@ -1172,16 +1174,20 @@ IMEStateManager::SetIMEState(const IMESt
NS_ENSURE_TRUE_VOID(aWidget);
InputContext context;
context.mIMEState = aState;
context.mOrigin = aOrigin;
context.mMayBeIMEUnaware = context.mIMEState.IsEditable() &&
sCheckForIMEUnawareWebApps && MayBeIMEUnawareWebApp(aContent);
+ context.mInPrivateBrowsing =
+ aPresContext &&
+ nsContentUtils::IsInPrivateBrowsing(aPresContext->Document());
+
if (aContent &&
aContent->IsAnyOfHTMLElements(nsGkAtoms::input, nsGkAtoms::textarea)) {
if (!aContent->IsHTMLElement(nsGkAtoms::textarea)) {
// <input type=number> has an anonymous <input type=text> descendant
// that gets focus whenever anyone tries to focus the number control. We
// need to check if aContent is one of those anonymous text controls and,
// if so, use the number control instead:
nsIContent* content = aContent;
@@ -1256,24 +1262,26 @@ IMEStateManager::SetIMEState(const IMESt
void
IMEStateManager::SetInputContext(nsIWidget* aWidget,
const InputContext& aInputContext,
const InputContextAction& aAction)
{
MOZ_LOG(sISMLog, LogLevel::Info,
("SetInputContext(aWidget=0x%p, aInputContext={ "
"mIMEState={ mEnabled=%s, mOpen=%s }, mHTMLInputType=\"%s\", "
- "mHTMLInputInputmode=\"%s\", mActionHint=\"%s\" }, "
+ "mHTMLInputInputmode=\"%s\", mActionHint=\"%s\", "
+ "mInPrivateBrowsing=%s }, "
"aAction={ mCause=%s, mAction=%s }), sActiveTabParent=0x%p",
aWidget,
GetIMEStateEnabledName(aInputContext.mIMEState.mEnabled),
GetIMEStateSetOpenName(aInputContext.mIMEState.mOpen),
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputType).get(),
NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputInputmode).get(),
NS_ConvertUTF16toUTF8(aInputContext.mActionHint).get(),
+ GetBoolName(aInputContext.mInPrivateBrowsing),
GetActionCauseName(aAction.mCause),
GetActionFocusChangeName(aAction.mFocusChange),
sActiveTabParent.get()));
MOZ_RELEASE_ASSERT(aWidget);
nsCOMPtr<nsIWidget> widget(aWidget);
widget->SetInputContext(aInputContext, aAction);