зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1240208 - use inputmode in XUL to get better hinting for IME and on-screen keyboards, r=masayuki,smaug
--HG-- extra : commitid : KANhgN15KJK extra : rebase_source : 0b640769e92d9d8c01e972c2b526ea56cc56d1df
This commit is contained in:
Родитель
6bc8a32265
Коммит
957a33f4d4
|
@ -37,7 +37,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|||
<html:input anonid="input"
|
||||
class="autocomplete-textbox urlbar-input textbox-input uri-element-right-align"
|
||||
allowevents="true"
|
||||
xbl:inherits="tooltiptext=inputtooltiptext,value,type=inputtype,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey"/>
|
||||
inputmode="url"
|
||||
xbl:inherits="tooltiptext=inputtooltiptext,value,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey"/>
|
||||
</xul:hbox>
|
||||
<xul:dropmarker anonid="historydropmarker"
|
||||
class="autocomplete-history-dropmarker urlbar-history-dropmarker"
|
||||
|
|
|
@ -1034,7 +1034,8 @@ IMEStateManager::SetIMEState(const IMEState& aState,
|
|||
context.mHTMLInputType.Assign(nsGkAtoms::textarea->GetUTF16String());
|
||||
}
|
||||
|
||||
if (Preferences::GetBool("dom.forms.inputmode", false)) {
|
||||
if (Preferences::GetBool("dom.forms.inputmode", false) ||
|
||||
nsContentUtils::IsChromeDoc(aContent->OwnerDoc())) {
|
||||
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::inputmode,
|
||||
context.mHTMLInputInputmode);
|
||||
}
|
||||
|
|
|
@ -3028,10 +3028,21 @@ TSFTextStore::InsertEmbedded(DWORD dwFlags,
|
|||
}
|
||||
|
||||
void
|
||||
TSFTextStore::SetInputScope(const nsString& aHTMLInputType)
|
||||
TSFTextStore::SetInputScope(const nsString& aHTMLInputType,
|
||||
const nsString& aHTMLInputInputMode)
|
||||
{
|
||||
mInputScopes.Clear();
|
||||
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
|
||||
if (aHTMLInputInputMode.EqualsLiteral("url")) {
|
||||
mInputScopes.AppendElement(IS_URL);
|
||||
} else if (aHTMLInputInputMode.EqualsLiteral("email")) {
|
||||
mInputScopes.AppendElement(IS_EMAIL_SMTPEMAILADDRESS);
|
||||
} else if (aHTMLInputType.EqualsLiteral("tel")) {
|
||||
mInputScopes.AppendElement(IS_TELEPHONE_FULLTELEPHONENUMBER);
|
||||
mInputScopes.AppendElement(IS_TELEPHONE_LOCALNUMBER);
|
||||
} else if (aHTMLInputType.EqualsLiteral("numeric")) {
|
||||
mInputScopes.AppendElement(IS_NUMBER);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4559,7 +4570,8 @@ TSFTextStore::CreateAndSetFocus(nsWindowBase* aFocusedWidget,
|
|||
"ITfTheadMgr::AssociateFocus() failure"));
|
||||
return false;
|
||||
}
|
||||
sEnabledTextStore->SetInputScope(aContext.mHTMLInputType);
|
||||
sEnabledTextStore->SetInputScope(aContext.mHTMLInputType,
|
||||
aContext.mHTMLInputInputmode);
|
||||
|
||||
if (sEnabledTextStore->mSink) {
|
||||
MOZ_LOG(sTextStoreLog, LogLevel::Info,
|
||||
|
@ -5296,7 +5308,8 @@ TSFTextStore::SetInputContext(nsWindowBase* aWidget,
|
|||
|
||||
if (aAction.mFocusChange != InputContextAction::FOCUS_NOT_CHANGED) {
|
||||
if (sEnabledTextStore) {
|
||||
sEnabledTextStore->SetInputScope(aContext.mHTMLInputType);
|
||||
sEnabledTextStore->SetInputScope(aContext.mHTMLInputType,
|
||||
aContext.mHTMLInputInputmode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -302,7 +302,8 @@ protected:
|
|||
HRESULT HandleRequestAttrs(DWORD aFlags,
|
||||
ULONG aFilterCount,
|
||||
const TS_ATTRID* aFilterAttrs);
|
||||
void SetInputScope(const nsString& aHTMLInputType);
|
||||
void SetInputScope(const nsString& aHTMLInputType,
|
||||
const nsString& aHTMLInputInputmode);
|
||||
|
||||
// Creates native caret over our caret. This method only works on desktop
|
||||
// application. Otherwise, this does nothing.
|
||||
|
|
|
@ -393,7 +393,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());
|
||||
SetInputScopeForIMM32(aWindow, EmptyString(), EmptyString());
|
||||
}
|
||||
#endif // #ifdef NS_ENABLE_TSF
|
||||
AssociateIMEContext(aWindow, true);
|
||||
|
@ -444,7 +444,8 @@ IMEHandler::SetInputContext(nsWindow* aWindow,
|
|||
}
|
||||
} else {
|
||||
// Set at least InputScope even when TextStore is not available.
|
||||
SetInputScopeForIMM32(aWindow, aInputContext.mHTMLInputType);
|
||||
SetInputScopeForIMM32(aWindow, aInputContext.mHTMLInputType,
|
||||
aInputContext.mHTMLInputInputmode);
|
||||
}
|
||||
#endif // #ifdef NS_ENABLE_TSF
|
||||
|
||||
|
@ -517,7 +518,8 @@ IMEHandler::CurrentKeyboardLayoutHasIME()
|
|||
// static
|
||||
void
|
||||
IMEHandler::SetInputScopeForIMM32(nsWindow* aWindow,
|
||||
const nsAString& aHTMLInputType)
|
||||
const nsAString& aHTMLInputType,
|
||||
const nsAString& aHTMLInputInputmode)
|
||||
{
|
||||
if (sIsInTSFMode || !sSetInputScopes || aWindow->Destroyed()) {
|
||||
return;
|
||||
|
@ -526,9 +528,28 @@ IMEHandler::SetInputScopeForIMM32(nsWindow* aWindow,
|
|||
const InputScope* scopes = nullptr;
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html
|
||||
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
|
||||
static const InputScope inputScopes[] = { IS_DEFAULT };
|
||||
scopes = &inputScopes[0];
|
||||
arraySize = ArrayLength(inputScopes);
|
||||
if (aHTMLInputInputmode.EqualsLiteral("url")) {
|
||||
static const InputScope inputScopes[] = { IS_URL };
|
||||
scopes = &inputScopes[0];
|
||||
arraySize = ArrayLength(inputScopes);
|
||||
} else if (aHTMLInputInputmode.EqualsLiteral("email")) {
|
||||
static const InputScope inputScopes[] = { IS_EMAIL_SMTPEMAILADDRESS };
|
||||
scopes = &inputScopes[0];
|
||||
arraySize = ArrayLength(inputScopes);
|
||||
} else if (aHTMLInputInputmode.EqualsLiteral("tel")) {
|
||||
static const InputScope inputScopes[] =
|
||||
{IS_TELEPHONE_LOCALNUMBER, IS_TELEPHONE_FULLTELEPHONENUMBER};
|
||||
scopes = &inputScopes[0];
|
||||
arraySize = ArrayLength(inputScopes);
|
||||
} else if (aHTMLInputInputmode.EqualsLiteral("numeric")) {
|
||||
static const InputScope inputScopes[] = { IS_NUMBER };
|
||||
scopes = &inputScopes[0];
|
||||
arraySize = ArrayLength(inputScopes);
|
||||
} else {
|
||||
static const InputScope inputScopes[] = { IS_DEFAULT };
|
||||
scopes = &inputScopes[0];
|
||||
arraySize = ArrayLength(inputScopes);
|
||||
}
|
||||
} else if (aHTMLInputType.EqualsLiteral("url")) {
|
||||
static const InputScope inputScopes[] = { IS_URL };
|
||||
scopes = &inputScopes[0];
|
||||
|
|
|
@ -131,7 +131,8 @@ private:
|
|||
#ifdef NS_ENABLE_TSF
|
||||
static decltype(SetInputScopes)* sSetInputScopes;
|
||||
static void SetInputScopeForIMM32(nsWindow* aWindow,
|
||||
const nsAString& aHTMLInputType);
|
||||
const nsAString& aHTMLInputType,
|
||||
const nsAString& aHTMLInputInputmode);
|
||||
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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче