summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dom/events/IMEStateManager.cpp24
-rw-r--r--dom/events/IMEStateManager.h1
-rw-r--r--widget/IMEData.h4
-rw-r--r--widget/windows/TSFTextStore.cpp15
-rw-r--r--widget/windows/TSFTextStore.h3
-rw-r--r--widget/windows/WinIMEHandler.cpp92
-rw-r--r--widget/windows/WinIMEHandler.h3
7 files changed, 75 insertions, 67 deletions
diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp
index 1c8ed63f0..80abad3cc 100644
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -297,7 +297,7 @@ IMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
- SetIMEState(newState, nullptr, sWidget, action);
+ SetIMEState(newState, nullptr, nullptr, sWidget, action);
}
sWidget = nullptr;
sContent = nullptr;
@@ -352,7 +352,7 @@ IMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
IMEState newState = GetNewIMEState(sPresContext, nullptr);
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::LOST_FOCUS);
- SetIMEState(newState, nullptr, sWidget, action);
+ SetIMEState(newState, aPresContext, nullptr, sWidget, action);
}
sWidget = nullptr;
@@ -542,7 +542,7 @@ IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
}
// Update IME state for new focus widget
- SetIMEState(newState, aContent, newWidget, aAction);
+ SetIMEState(newState, aPresContext, aContent, newWidget, aAction);
}
sActiveTabParent = newTabParent;
@@ -704,7 +704,7 @@ IMEStateManager::OnClickInEditor(nsPresContext* aPresContext,
InputContextAction action(cause, InputContextAction::FOCUS_NOT_CHANGED);
IMEState newState = GetNewIMEState(aPresContext, aContent);
- SetIMEState(newState, aContent, widget, action);
+ SetIMEState(newState, aPresContext, aContent, widget, action);
}
// static
@@ -912,7 +912,7 @@ IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
if (updateIMEState) {
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
InputContextAction::FOCUS_NOT_CHANGED);
- SetIMEState(aNewIMEState, aContent, widget, action);
+ SetIMEState(aNewIMEState, sPresContext, aContent, widget, action);
if (NS_WARN_IF(widget->Destroyed())) {
MOZ_LOG(sISMLog, LogLevel::Error,
(" UpdateIMEState(), widget has gone during setting input context"));
@@ -1022,8 +1022,8 @@ IMEStateManager::SetInputContextForChildProcess(
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),
@@ -1031,6 +1031,7 @@ IMEStateManager::SetInputContextForChildProcess(
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)),
@@ -1070,6 +1071,7 @@ IMEStateManager::SetInputContextForChildProcess(
// static
void
IMEStateManager::SetIMEState(const IMEState& aState,
+ nsPresContext* aPresContext,
nsIContent* aContent,
nsIWidget* aWidget,
InputContextAction aAction)
@@ -1090,6 +1092,10 @@ IMEStateManager::SetIMEState(const IMEState& aState,
context.mIMEState = aState;
context.mMayBeIMEUnaware = context.mIMEState.IsEditable() &&
sCheckForIMEUnawareWebApps && MayBeIMEUnawareWebApp(aContent);
+
+ context.mInPrivateBrowsing =
+ aPresContext &&
+ nsContentUtils::IsInPrivateBrowsing(aPresContext->Document());
if (aContent &&
aContent->IsAnyOfHTMLElements(nsGkAtoms::input, nsGkAtoms::textarea)) {
@@ -1175,7 +1181,8 @@ IMEStateManager::SetInputContext(nsIWidget* aWidget,
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),
@@ -1183,6 +1190,7 @@ IMEStateManager::SetInputContext(nsIWidget* aWidget,
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()));
diff --git a/dom/events/IMEStateManager.h b/dom/events/IMEStateManager.h
index 7dfc48aa5..34509847f 100644
--- a/dom/events/IMEStateManager.h
+++ b/dom/events/IMEStateManager.h
@@ -247,6 +247,7 @@ protected:
nsIContent* aContent,
InputContextAction aAction);
static void SetIMEState(const IMEState &aState,
+ nsPresContext* aPresContext,
nsIContent* aContent,
nsIWidget* aWidget,
InputContextAction aAction);
diff --git a/widget/IMEData.h b/widget/IMEData.h
index b12497be3..04245df26 100644
--- a/widget/IMEData.h
+++ b/widget/IMEData.h
@@ -300,6 +300,10 @@ struct InputContext final
* compatibility with webapps relying on key listeners. */
bool mMayBeIMEUnaware;
+ /* Whether the owning document of the input element has been loaded
+ * in private browsing mode. */
+ bool mInPrivateBrowsing;
+
bool IsOriginMainProcess() const
{
return mOrigin == ORIGIN_MAIN;
diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp
index c80de831c..12b8cd0c1 100644
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1355,7 +1355,9 @@ TSFTextStore::Init(nsWindowBase* aWidget,
return false;
}
- SetInputScope(aContext.mHTMLInputType, aContext.mHTMLInputInputmode);
+ SetInputScope(aContext.mHTMLInputType,
+ aContext.mHTMLInputInputmode,
+ aContext.mInPrivateBrowsing);
// Create document manager
RefPtr<ITfThreadMgr> threadMgr = sThreadMgr;
@@ -3205,9 +3207,15 @@ TSFTextStore::InsertEmbedded(DWORD dwFlags,
void
TSFTextStore::SetInputScope(const nsString& aHTMLInputType,
- const nsString& aHTMLInputInputMode)
+ const nsString& aHTMLInputInputMode,
+ bool aInPrivateBrowsing)
{
mInputScopes.Clear();
+
+ if (aInPrivateBrowsing) {
+ mInputScopes.AppendElement(IS_PRIVATE);
+ }
+
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
if (aHTMLInputInputMode.EqualsLiteral("url")) {
mInputScopes.AppendElement(IS_URL);
@@ -5688,7 +5696,8 @@ TSFTextStore::SetInputContext(nsWindowBase* aWidget,
if (sEnabledTextStore) {
RefPtr<TSFTextStore> textStore(sEnabledTextStore);
textStore->SetInputScope(aContext.mHTMLInputType,
- aContext.mHTMLInputInputmode);
+ aContext.mHTMLInputInputmode,
+ aContext.mInPrivateBrowsing);
}
return;
}
diff --git a/widget/windows/TSFTextStore.h b/widget/windows/TSFTextStore.h
index 9596510d5..d1431e95d 100644
--- a/widget/windows/TSFTextStore.h
+++ b/widget/windows/TSFTextStore.h
@@ -355,7 +355,8 @@ protected:
ULONG aFilterCount,
const TS_ATTRID* aFilterAttrs);
void SetInputScope(const nsString& aHTMLInputType,
- const nsString& aHTMLInputInputmode);
+ const nsString& aHTMLInputInputmode,
+ bool aInPrivateBrowsing);
// Creates native caret over our caret. This method only works on desktop
// application. Otherwise, this does nothing.
diff --git a/widget/windows/WinIMEHandler.cpp b/widget/windows/WinIMEHandler.cpp
index d44f729c4..9debaa2dd 100644
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -409,7 +409,7 @@ IMEHandler::OnDestroyWindow(nsWindow* aWindow)
if (!sIsInTSFMode) {
// MSDN says we need to set IS_DEFAULT to avoid memory leak when we use
// SetInputScopes API. Use an empty string to do this.
- SetInputScopeForIMM32(aWindow, EmptyString(), EmptyString());
+ SetInputScopeForIMM32(aWindow, EmptyString(), EmptyString(), false);
}
#endif // #ifdef NS_ENABLE_TSF
AssociateIMEContext(aWindow, true);
@@ -481,8 +481,10 @@ IMEHandler::SetInputContext(nsWindow* aWindow,
}
} else {
// Set at least InputScope even when TextStore is not available.
- SetInputScopeForIMM32(aWindow, aInputContext.mHTMLInputType,
- aInputContext.mHTMLInputInputmode);
+ SetInputScopeForIMM32(aWindow,
+ aInputContext.mHTMLInputType,
+ aInputContext.mHTMLInputInputmode,
+ aInputContext.mInPrivateBrowsing);
}
#endif // #ifdef NS_ENABLE_TSF
@@ -583,82 +585,64 @@ IMEHandler::OnKeyboardLayoutChanged()
void
IMEHandler::SetInputScopeForIMM32(nsWindow* aWindow,
const nsAString& aHTMLInputType,
- const nsAString& aHTMLInputInputmode)
+ const nsAString& aHTMLInputInputmode,
+ bool aInPrivateBrowsing)
{
if (sIsInTSFMode || !sSetInputScopes || aWindow->Destroyed()) {
return;
}
- UINT arraySize = 0;
- const InputScope* scopes = nullptr;
+ AutoTArray<InputScope, 3> scopes;
+
+ if (aInPrivateBrowsing) {
+ scopes.AppendElement(IS_PRIVATE);
+ }
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
if (aHTMLInputInputmode.EqualsLiteral("url")) {
- static const InputScope inputScopes[] = { IS_URL };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_URL);
} else if (aHTMLInputInputmode.EqualsLiteral("email")) {
- static const InputScope inputScopes[] = { IS_EMAIL_SMTPEMAILADDRESS };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_EMAIL_SMTPEMAILADDRESS);
} else if (aHTMLInputInputmode.EqualsLiteral("tel")) {
- static const InputScope inputScopes[] =
- {IS_TELEPHONE_LOCALNUMBER, IS_TELEPHONE_FULLTELEPHONENUMBER};
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_TELEPHONE_LOCALNUMBER);
+ scopes.AppendElement(IS_TELEPHONE_FULLTELEPHONENUMBER);
} else if (aHTMLInputInputmode.EqualsLiteral("numeric")) {
- static const InputScope inputScopes[] = { IS_NUMBER };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_NUMBER);
} else {
- static const InputScope inputScopes[] = { IS_DEFAULT };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_DEFAULT);
}
} else if (aHTMLInputType.EqualsLiteral("url")) {
- static const InputScope inputScopes[] = { IS_URL };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_URL);
} else if (aHTMLInputType.EqualsLiteral("search")) {
- static const InputScope inputScopes[] = { IS_SEARCH };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_SEARCH);
} else if (aHTMLInputType.EqualsLiteral("email")) {
- static const InputScope inputScopes[] = { IS_EMAIL_SMTPEMAILADDRESS };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_EMAIL_SMTPEMAILADDRESS);
} else if (aHTMLInputType.EqualsLiteral("password")) {
- static const InputScope inputScopes[] = { IS_PASSWORD };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_PASSWORD);
} else if (aHTMLInputType.EqualsLiteral("datetime") ||
aHTMLInputType.EqualsLiteral("datetime-local")) {
- static const InputScope inputScopes[] = {
- IS_DATE_FULLDATE, IS_TIME_FULLTIME };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_DATE_FULLDATE);
+ scopes.AppendElement(IS_TIME_FULLTIME);
} else if (aHTMLInputType.EqualsLiteral("date") ||
aHTMLInputType.EqualsLiteral("month") ||
aHTMLInputType.EqualsLiteral("week")) {
- static const InputScope inputScopes[] = { IS_DATE_FULLDATE };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_DATE_FULLDATE);
} else if (aHTMLInputType.EqualsLiteral("time")) {
- static const InputScope inputScopes[] = { IS_TIME_FULLTIME };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_TIME_FULLTIME);
} else if (aHTMLInputType.EqualsLiteral("tel")) {
- static const InputScope inputScopes[] = {
- IS_TELEPHONE_FULLTELEPHONENUMBER, IS_TELEPHONE_LOCALNUMBER };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_TELEPHONE_FULLTELEPHONENUMBER);
+ scopes.AppendElement(IS_TELEPHONE_LOCALNUMBER);
} else if (aHTMLInputType.EqualsLiteral("number")) {
- static const InputScope inputScopes[] = { IS_NUMBER };
- scopes = &inputScopes[0];
- arraySize = ArrayLength(inputScopes);
+ scopes.AppendElement(IS_NUMBER);
}
- if (scopes && arraySize > 0) {
- sSetInputScopes(aWindow->GetWindowHandle(), scopes, arraySize, nullptr, 0,
- nullptr, nullptr);
+ if (!scopes.IsEmpty()) {
+ sSetInputScopes(aWindow->GetWindowHandle(),
+ scopes.Elements(),
+ scopes.Length(),
+ nullptr,
+ 0,
+ nullptr,
+ nullptr);
}
}
diff --git a/widget/windows/WinIMEHandler.h b/widget/windows/WinIMEHandler.h
index c18a4437e..c836e8626 100644
--- a/widget/windows/WinIMEHandler.h
+++ b/widget/windows/WinIMEHandler.h
@@ -144,7 +144,8 @@ private:
static decltype(SetInputScopes)* sSetInputScopes;
static void SetInputScopeForIMM32(nsWindow* aWindow,
const nsAString& aHTMLInputType,
- const nsAString& aHTMLInputInputmode);
+ const nsAString& aHTMLInputInputmode,
+ bool aInPrivateBrowsing);
static bool sIsInTSFMode;
// If sIMMEnabled is false, any IME messages are not handled in TSF mode.
// Additionally, IME context is always disassociated from focused window.