зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1549394 - Part 2. Set IS_PRIVATE input scope in private browsing. r=masayuki
Microsoft IME on Windows 10 20H1 (build 19025+) supports IME private mode by input scope. Although previous Windows version uses undocumented API for Edge and IE only, next Windows will use public API for it. So let's use IS_PRIVATE input scope in private browsing mode. Differential Revision: https://phabricator.services.mozilla.com/D53918 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fe859b69f4
Коммит
546edaf1e6
|
@ -906,6 +906,11 @@ class GetInputScopeString : public nsAutoCString {
|
|||
case IS_XML:
|
||||
AppendLiteral("IS_XML");
|
||||
break;
|
||||
#ifndef __MINGW32__
|
||||
case IS_PRIVATE:
|
||||
AppendLiteral("IS_PRIVATE");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
AppendPrintf("Unknown Value(%d)", inputScope);
|
||||
break;
|
||||
|
@ -1913,7 +1918,8 @@ bool TSFTextStore::Init(nsWindowBase* aWidget, const InputContext& aContext) {
|
|||
return false;
|
||||
}
|
||||
|
||||
SetInputScope(aContext.mHTMLInputType, aContext.mHTMLInputInputmode);
|
||||
SetInputScope(aContext.mHTMLInputType, aContext.mHTMLInputInputmode,
|
||||
aContext.mInPrivateBrowsing);
|
||||
|
||||
// Create document manager
|
||||
RefPtr<ITfThreadMgr> threadMgr = sThreadMgr;
|
||||
|
@ -3958,8 +3964,17 @@ bool TSFTextStore::ShouldSetInputScopeOfURLBarToDefault() {
|
|||
}
|
||||
|
||||
void TSFTextStore::SetInputScope(const nsString& aHTMLInputType,
|
||||
const nsString& aHTMLInputInputMode) {
|
||||
const nsString& aHTMLInputInputMode,
|
||||
bool aInPrivateBrowsing) {
|
||||
mInputScopes.Clear();
|
||||
|
||||
#ifndef __MINGW32__
|
||||
// MinGW build environment doesn't have IS_PRIVATE yet.
|
||||
if (aInPrivateBrowsing) {
|
||||
mInputScopes.AppendElement(IS_PRIVATE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
|
||||
if (aHTMLInputInputMode.EqualsLiteral("url")) {
|
||||
mInputScopes.AppendElement(IS_URL);
|
||||
|
@ -6718,7 +6733,8 @@ void TSFTextStore::SetInputContext(nsWindowBase* aWidget,
|
|||
if (sEnabledTextStore) {
|
||||
RefPtr<TSFTextStore> textStore(sEnabledTextStore);
|
||||
textStore->SetInputScope(aContext.mHTMLInputType,
|
||||
aContext.mHTMLInputInputmode);
|
||||
aContext.mHTMLInputInputmode,
|
||||
aContext.mInPrivateBrowsing);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -348,7 +348,8 @@ class TSFTextStore final : public ITextStoreACP,
|
|||
HRESULT HandleRequestAttrs(DWORD aFlags, 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.
|
||||
|
|
|
@ -452,7 +452,7 @@ void 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);
|
||||
|
@ -513,7 +513,8 @@ void IMEHandler::SetInputContext(nsWindow* aWindow, InputContext& aInputContext,
|
|||
} else {
|
||||
// Set at least InputScope even when TextStore is not available.
|
||||
SetInputScopeForIMM32(aWindow, aInputContext.mHTMLInputType,
|
||||
aInputContext.mHTMLInputInputmode);
|
||||
aInputContext.mHTMLInputInputmode,
|
||||
aInputContext.mInPrivateBrowsing);
|
||||
}
|
||||
#endif // #ifdef NS_ENABLE_TSF
|
||||
|
||||
|
@ -635,12 +636,19 @@ void IMEHandler::OnKeyboardLayoutChanged() {
|
|||
// static
|
||||
void IMEHandler::SetInputScopeForIMM32(nsWindow* aWindow,
|
||||
const nsAString& aHTMLInputType,
|
||||
const nsAString& aHTMLInputInputmode) {
|
||||
const nsAString& aHTMLInputInputmode,
|
||||
bool aInPrivateBrowsing) {
|
||||
if (sIsInTSFMode || !sSetInputScopes || aWindow->Destroyed()) {
|
||||
return;
|
||||
}
|
||||
AutoTArray<InputScope, 3> scopes;
|
||||
|
||||
#ifndef __MINGW32__
|
||||
if (aInPrivateBrowsing) {
|
||||
scopes.AppendElement(IS_PRIVATE);
|
||||
}
|
||||
#endif
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html
|
||||
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
|
||||
if (aHTMLInputInputmode.EqualsLiteral("url")) {
|
||||
|
|
|
@ -199,7 +199,8 @@ class IMEHandler final {
|
|||
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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче