summaryrefslogtreecommitdiffstats
path: root/widget/windows/WinIMEHandler.cpp
diff options
context:
space:
mode:
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>2020-01-09 09:53:16 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-01-09 09:53:16 +0100
commit1672355a777e96d2c92c308d2429247d6209999c (patch)
tree7d0c27d1bb151dc6ed8b976d61a7a8a4ef3fe02c /widget/windows/WinIMEHandler.cpp
parentc0326517787e12bb5904d8f55386499628806b42 (diff)
downloadUXP-1672355a777e96d2c92c308d2429247d6209999c.tar
UXP-1672355a777e96d2c92c308d2429247d6209999c.tar.gz
UXP-1672355a777e96d2c92c308d2429247d6209999c.tar.lz
UXP-1672355a777e96d2c92c308d2429247d6209999c.tar.xz
UXP-1672355a777e96d2c92c308d2429247d6209999c.zip
Issue #1348 - Part 1: Clean up input scope support for IMM32.
Use AutoTArray to set input scope.
Diffstat (limited to 'widget/windows/WinIMEHandler.cpp')
-rw-r--r--widget/windows/WinIMEHandler.cpp76
1 files changed, 26 insertions, 50 deletions
diff --git a/widget/windows/WinIMEHandler.cpp b/widget/windows/WinIMEHandler.cpp
index d44f729c4..99f0fb136 100644
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -588,77 +588,53 @@ IMEHandler::SetInputScopeForIMM32(nsWindow* aWindow,
if (sIsInTSFMode || !sSetInputScopes || aWindow->Destroyed()) {
return;
}
- UINT arraySize = 0;
- const InputScope* scopes = nullptr;
+ AutoTArray<InputScope, 3> scopes;
// 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);
}
}