mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1683226 - part 1: Make IMEState::Enabled
an enum class r=m_kato,geckoview-reviewers
Before deleting `IMEState::Enabled::PLUGIN`, let's make it an enum class for making the change safer. Almost all of this change is done by "replace" of VSCode. Differential Revision: https://phabricator.services.mozilla.com/D100100
This commit is contained in:
parent
963794deaa
commit
d27602eee6
@ -199,7 +199,7 @@ nsIContent::IMEState nsIContent::GetDesiredIMEState() {
|
||||
// have the editable flag set, but are readwrite (such as text controls).
|
||||
if (!IsElement() ||
|
||||
!AsElement()->State().HasState(NS_EVENT_STATE_READWRITE)) {
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
}
|
||||
// NOTE: The content for independent editors (e.g., input[type=text],
|
||||
@ -213,15 +213,15 @@ nsIContent::IMEState nsIContent::GetDesiredIMEState() {
|
||||
}
|
||||
Document* doc = GetComposedDoc();
|
||||
if (!doc) {
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
nsPresContext* pc = doc->GetPresContext();
|
||||
if (!pc) {
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
HTMLEditor* htmlEditor = nsContentUtils::GetHTMLEditor(pc);
|
||||
if (!htmlEditor) {
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
IMEState state;
|
||||
htmlEditor->GetPreferredIMEState(&state);
|
||||
|
@ -1751,7 +1751,7 @@ nsDOMWindowUtils::GetIMEIsOpen(bool* aState) {
|
||||
|
||||
// Open state should not be available when IME is not enabled.
|
||||
InputContext context = widget->GetInputContext();
|
||||
if (context.mIMEState.mEnabled != IMEState::ENABLED) {
|
||||
if (context.mIMEState.mEnabled != IMEEnabled::Enabled) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class ShadowRoot;
|
||||
class HTMLSlotElement;
|
||||
} // namespace dom
|
||||
namespace widget {
|
||||
enum class IMEEnabled;
|
||||
struct IMEState;
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
@ -49,6 +50,7 @@ enum nsLinkState {
|
||||
*/
|
||||
class nsIContent : public nsINode {
|
||||
public:
|
||||
using IMEEnabled = mozilla::widget::IMEEnabled;
|
||||
using IMEState = mozilla::widget::IMEState;
|
||||
using BindContext = mozilla::dom::BindContext;
|
||||
|
||||
@ -340,14 +342,14 @@ class nsIContent : public nsINode {
|
||||
* @return The desired IME status for the content.
|
||||
* This is a combination of an IME enabled value and
|
||||
* an IME open value of widget::IMEState.
|
||||
* If you return DISABLED, you should not set the OPEN and CLOSE
|
||||
* value.
|
||||
* PASSWORD should be returned only from password editor, this value
|
||||
* has a special meaning. It is used as alternative of DISABLED.
|
||||
* PLUGIN should be returned only when plug-in has focus. When a
|
||||
* plug-in is focused content, we should send native events directly.
|
||||
* Because we don't process some native events, but they may be needed
|
||||
* by the plug-in.
|
||||
* If you return IMEEnabled::Disabled, you should not set the OPEN
|
||||
* nor CLOSE value.
|
||||
* IMEEnabled::Password should be returned only from password editor,
|
||||
* this value has a special meaning. It is used as alternative of
|
||||
* IMEEnabled::Disabled. IMEENabled::Plugin should be returned only
|
||||
* when plug-in has focus. When a plug-in is focused content, we
|
||||
* should send native events directly. Because we don't process some
|
||||
* native events, but they may be needed by the plug-in.
|
||||
*/
|
||||
virtual IMEState GetDesiredIMEState();
|
||||
|
||||
|
@ -1815,7 +1815,7 @@ nsObjectLoadingContent::UpdateObjectParameters() {
|
||||
MOZ_ASSERT(thisContent, "should have content");
|
||||
if (updateIMEState && thisContent && fm && fm->IsFocused(thisContent)) {
|
||||
widget::IMEState state;
|
||||
state.mEnabled = widget::IMEState::PLUGIN;
|
||||
state.mEnabled = widget::IMEEnabled::Plugin;
|
||||
state.mOpen = widget::IMEState::DONT_CHANGE_OPEN_STATE;
|
||||
IMEStateManager::UpdateIMEState(state, thisContent, nullptr);
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ nsIContent* ContentEventHandler::GetFocusedContent() {
|
||||
|
||||
bool ContentEventHandler::IsPlugin(nsIContent* aContent) {
|
||||
return aContent &&
|
||||
aContent->GetDesiredIMEState().mEnabled == IMEState::PLUGIN;
|
||||
aContent->GetDesiredIMEState().mEnabled == IMEEnabled::Plugin;
|
||||
}
|
||||
|
||||
nsresult ContentEventHandler::QueryContentRect(
|
||||
|
@ -162,7 +162,7 @@ void IMEContentObserver::Init(nsIWidget* aWidget, nsPresContext* aPresContext,
|
||||
mWidget = aWidget;
|
||||
mIMENotificationRequests = &mWidget->IMENotificationRequestsRef();
|
||||
|
||||
if (aWidget->GetInputContext().mIMEState.mEnabled == IMEState::PLUGIN) {
|
||||
if (aWidget->GetInputContext().mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
if (!InitWithPlugin(aPresContext, aContent)) {
|
||||
Clear();
|
||||
return;
|
||||
@ -304,7 +304,8 @@ bool IMEContentObserver::InitWithEditor(nsPresContext* aPresContext,
|
||||
bool IMEContentObserver::InitWithPlugin(nsPresContext* aPresContext,
|
||||
nsIContent* aContent) {
|
||||
if (NS_WARN_IF(!aContent) ||
|
||||
NS_WARN_IF(aContent->GetDesiredIMEState().mEnabled != IMEState::PLUGIN)) {
|
||||
NS_WARN_IF(aContent->GetDesiredIMEState().mEnabled !=
|
||||
IMEEnabled::Plugin)) {
|
||||
return false;
|
||||
}
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
|
@ -564,7 +564,7 @@ nsresult IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
|
||||
// If a child process has focus, we should disable IME state until the child
|
||||
// process actually gets focus because if user types keys before that they
|
||||
// are handled by IME.
|
||||
IMEState newState = remoteHasFocus ? IMEState(IMEState::DISABLED)
|
||||
IMEState newState = remoteHasFocus ? IMEState(IMEEnabled::Disabled)
|
||||
: GetNewIMEState(aPresContext, aContent);
|
||||
bool setIMEState = true;
|
||||
|
||||
@ -586,7 +586,7 @@ nsresult IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
|
||||
}
|
||||
} else if (focusActuallyChanging) {
|
||||
InputContext context = newWidget->GetInputContext();
|
||||
if (context.mIMEState.mEnabled == IMEState::DISABLED &&
|
||||
if (context.mIMEState.mEnabled == IMEEnabled::Disabled &&
|
||||
context.mOrigin == InputContext::ORIGIN_CONTENT) {
|
||||
setIMEState = false;
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
@ -643,7 +643,7 @@ nsresult IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
|
||||
} else if (aAction.mFocusChange == InputContextAction::FOCUS_NOT_CHANGED) {
|
||||
// If aContent isn't null or aContent is null but editable, somebody gets
|
||||
// focus.
|
||||
bool gotFocus = aContent || (newState.mEnabled == IMEState::ENABLED);
|
||||
bool gotFocus = aContent || (newState.mEnabled == IMEEnabled::Enabled);
|
||||
aAction.mFocusChange = gotFocus ? InputContextAction::GOT_FOCUS
|
||||
: InputContextAction::LOST_FOCUS;
|
||||
}
|
||||
@ -667,7 +667,7 @@ nsresult IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
|
||||
// Don't call CreateIMEContentObserver() here except when a plugin gets
|
||||
// focus because it will be called from the focus event handler of focused
|
||||
// editor.
|
||||
if (newState.mEnabled == IMEState::PLUGIN) {
|
||||
if (newState.mEnabled == IMEEnabled::Plugin) {
|
||||
CreateIMEContentObserver(nullptr);
|
||||
if (sActiveIMEContentObserver) {
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
@ -1087,25 +1087,25 @@ IMEState IMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
|
||||
|
||||
if (!CanHandleWith(aPresContext)) {
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
(" GetNewIMEState() returns DISABLED because "
|
||||
(" GetNewIMEState() returns IMEEnabled::Disabled because "
|
||||
"the nsPresContext has been destroyed"));
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
|
||||
// On Printing or Print Preview, we don't need IME.
|
||||
if (aPresContext->Type() == nsPresContext::eContext_PrintPreview ||
|
||||
aPresContext->Type() == nsPresContext::eContext_Print) {
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
(" GetNewIMEState() returns DISABLED because "
|
||||
(" GetNewIMEState() returns IMEEnabled::Disabled because "
|
||||
"the nsPresContext is for print or print preview"));
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
|
||||
if (sInstalledMenuKeyboardListener) {
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
(" GetNewIMEState() returns DISABLED because "
|
||||
(" GetNewIMEState() returns IMEEnabled::Disabled because "
|
||||
"menu keyboard listener was installed"));
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
|
||||
if (!aContent) {
|
||||
@ -1114,14 +1114,14 @@ IMEState IMEStateManager::GetNewIMEState(nsPresContext* aPresContext,
|
||||
Document* doc = aPresContext->Document();
|
||||
if (doc && doc->HasFlag(NODE_IS_EDITABLE)) {
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
(" GetNewIMEState() returns ENABLED because "
|
||||
(" GetNewIMEState() returns IMEEnabled::Enabled because "
|
||||
"design mode editor has focus"));
|
||||
return IMEState(IMEState::ENABLED);
|
||||
return IMEState(IMEEnabled::Enabled);
|
||||
}
|
||||
MOZ_LOG(sISMLog, LogLevel::Debug,
|
||||
(" GetNewIMEState() returns DISABLED because "
|
||||
(" GetNewIMEState() returns IMEEnabled::Disabled because "
|
||||
"no content has focus"));
|
||||
return IMEState(IMEState::DISABLED);
|
||||
return IMEState(IMEEnabled::Disabled);
|
||||
}
|
||||
|
||||
// nsIContent::GetDesiredIMEState() may cause a call of UpdateIMEState()
|
||||
@ -1156,12 +1156,12 @@ static bool MayBeIMEUnawareWebApp(nsINode* aNode) {
|
||||
|
||||
// static
|
||||
void IMEStateManager::ResetActiveChildInputContext() {
|
||||
sActiveChildInputContext.mIMEState.mEnabled = IMEState::UNKNOWN;
|
||||
sActiveChildInputContext.mIMEState.mEnabled = IMEEnabled::Unknown;
|
||||
}
|
||||
|
||||
// static
|
||||
bool IMEStateManager::HasActiveChildSetInputContext() {
|
||||
return sActiveChildInputContext.mIMEState.mEnabled != IMEState::UNKNOWN;
|
||||
return sActiveChildInputContext.mIMEState.mEnabled != IMEEnabled::Unknown;
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -188,7 +188,7 @@ bool HTMLEmbedElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
||||
|
||||
nsIContent::IMEState HTMLEmbedElement::GetDesiredIMEState() {
|
||||
if (Type() == eType_Plugin) {
|
||||
return IMEState(IMEState::PLUGIN);
|
||||
return IMEState(IMEEnabled::Plugin);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::GetDesiredIMEState();
|
||||
|
@ -339,7 +339,7 @@ bool HTMLObjectElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
||||
|
||||
nsIContent::IMEState HTMLObjectElement::GetDesiredIMEState() {
|
||||
if (Type() == eType_Plugin) {
|
||||
return IMEState(IMEState::PLUGIN);
|
||||
return IMEState(IMEEnabled::Plugin);
|
||||
}
|
||||
|
||||
return nsGenericHTMLFormElement::GetDesiredIMEState();
|
||||
|
@ -3190,7 +3190,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvGetInputContext(
|
||||
widget::IMEState* aState) {
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
if (!widget) {
|
||||
*aState = widget::IMEState(IMEState::DISABLED,
|
||||
*aState = widget::IMEState(IMEEnabled::Disabled,
|
||||
IMEState::OPEN_STATE_NOT_SUPPORTED);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -1966,11 +1966,11 @@ nsresult EditorBase::GetPreferredIMEState(IMEState* aState) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
aState->mEnabled = IMEState::ENABLED;
|
||||
aState->mEnabled = IMEEnabled::Enabled;
|
||||
aState->mOpen = IMEState::DONT_CHANGE_OPEN_STATE;
|
||||
|
||||
if (IsReadonly()) {
|
||||
aState->mEnabled = IMEState::DISABLED;
|
||||
aState->mEnabled = IMEEnabled::Disabled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1987,12 +1987,12 @@ nsresult EditorBase::GetPreferredIMEState(IMEState* aState) {
|
||||
switch (frameForRootElement->StyleUIReset()->mIMEMode) {
|
||||
case StyleImeMode::Auto:
|
||||
if (IsPasswordEditor()) {
|
||||
aState->mEnabled = IMEState::PASSWORD;
|
||||
aState->mEnabled = IMEEnabled::Password;
|
||||
}
|
||||
break;
|
||||
case StyleImeMode::Disabled:
|
||||
// we should use password state for |ime-mode: disabled;|.
|
||||
aState->mEnabled = IMEState::PASSWORD;
|
||||
aState->mEnabled = IMEEnabled::Password;
|
||||
break;
|
||||
case StyleImeMode::Active:
|
||||
aState->mOpen = IMEState::OPEN;
|
||||
|
@ -6348,9 +6348,9 @@ nsresult HTMLEditor::GetPreferredIMEState(IMEState* aState) {
|
||||
// HTML editor don't prefer the CSS ime-mode because IE didn't do so too.
|
||||
aState->mOpen = IMEState::DONT_CHANGE_OPEN_STATE;
|
||||
if (IsReadonly()) {
|
||||
aState->mEnabled = IMEState::DISABLED;
|
||||
aState->mEnabled = IMEEnabled::Disabled;
|
||||
} else {
|
||||
aState->mEnabled = IMEState::ENABLED;
|
||||
aState->mEnabled = IMEEnabled::Enabled;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -164,25 +164,20 @@ nsCString PrintStringDetail::PrintCharData(char32_t aChar) {
|
||||
|
||||
namespace widget {
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const IMEState::Enabled& aEnabled) {
|
||||
std::ostream& operator<<(std::ostream& aStream, const IMEEnabled& aEnabled) {
|
||||
switch (aEnabled) {
|
||||
case IMEState::DISABLED:
|
||||
aStream << "DISABLED";
|
||||
break;
|
||||
case IMEState::ENABLED:
|
||||
aStream << "ENABLED";
|
||||
break;
|
||||
case IMEState::PASSWORD:
|
||||
aStream << "PASSWORD";
|
||||
break;
|
||||
case IMEState::PLUGIN:
|
||||
aStream << "PLUGIN";
|
||||
break;
|
||||
default:
|
||||
aStream << "illegal value";
|
||||
break;
|
||||
case IMEEnabled::Disabled:
|
||||
return aStream << "DISABLED";
|
||||
case IMEEnabled::Enabled:
|
||||
return aStream << "ENABLED";
|
||||
case IMEEnabled::Password:
|
||||
return aStream << "PASSWORD";
|
||||
case IMEEnabled::Plugin:
|
||||
return aStream << "PLUGIN";
|
||||
case IMEEnabled::Unknown:
|
||||
return aStream << "illegal value";
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("Add a case to handle your new IMEEnabled value");
|
||||
return aStream;
|
||||
}
|
||||
|
||||
|
@ -256,52 +256,50 @@ struct IMENotificationRequests final {
|
||||
Notifications mWantUpdates;
|
||||
};
|
||||
|
||||
/**
|
||||
* IME enabled states.
|
||||
*
|
||||
* WARNING: If you change these values, you also need to edit:
|
||||
* nsIDOMWindowUtils.idl
|
||||
*/
|
||||
enum class IMEEnabled {
|
||||
/**
|
||||
* 'Disabled' means the user cannot use IME. So, the IME open state should
|
||||
* be 'closed' during 'disabled'.
|
||||
*/
|
||||
Disabled,
|
||||
/**
|
||||
* 'Enabled' means the user can use IME.
|
||||
*/
|
||||
Enabled,
|
||||
/**
|
||||
* 'Password' state is a special case for the password editors.
|
||||
* E.g., on mac, the password editors should disable the non-Roman
|
||||
* keyboard layouts at getting focus. Thus, the password editor may have
|
||||
* special rules on some platforms.
|
||||
*/
|
||||
Password,
|
||||
/**
|
||||
* This state is used when a plugin is focused.
|
||||
* When a plug-in is focused content, we should send native events
|
||||
* directly. Because we don't process some native events, but they may
|
||||
* be needed by the plug-in.
|
||||
*/
|
||||
Plugin,
|
||||
/**
|
||||
* 'Unknown' is useful when you cache this enum. So, this shouldn't be
|
||||
* used with nsIWidget::SetInputContext().
|
||||
*/
|
||||
Unknown,
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains IMEStatus plus information about the current
|
||||
* input context that the IME can use as hints if desired.
|
||||
*/
|
||||
|
||||
struct IMEState final {
|
||||
/**
|
||||
* IME enabled states, the mEnabled value of
|
||||
* SetInputContext()/GetInputContext() should be one value of following
|
||||
* values.
|
||||
*
|
||||
* WARNING: If you change these values, you also need to edit:
|
||||
* nsIDOMWindowUtils.idl
|
||||
* nsContentUtils::GetWidgetStatusFromIMEStatus
|
||||
*/
|
||||
enum Enabled {
|
||||
/**
|
||||
* 'Disabled' means the user cannot use IME. So, the IME open state should
|
||||
* be 'closed' during 'disabled'.
|
||||
*/
|
||||
DISABLED,
|
||||
/**
|
||||
* 'Enabled' means the user can use IME.
|
||||
*/
|
||||
ENABLED,
|
||||
/**
|
||||
* 'Password' state is a special case for the password editors.
|
||||
* E.g., on mac, the password editors should disable the non-Roman
|
||||
* keyboard layouts at getting focus. Thus, the password editor may have
|
||||
* special rules on some platforms.
|
||||
*/
|
||||
PASSWORD,
|
||||
/**
|
||||
* This state is used when a plugin is focused.
|
||||
* When a plug-in is focused content, we should send native events
|
||||
* directly. Because we don't process some native events, but they may
|
||||
* be needed by the plug-in.
|
||||
*/
|
||||
PLUGIN,
|
||||
/**
|
||||
* 'Unknown' is useful when you cache this enum. So, this shouldn't be
|
||||
* used with nsIWidget::SetInputContext().
|
||||
*/
|
||||
UNKNOWN
|
||||
};
|
||||
Enabled mEnabled;
|
||||
IMEEnabled mEnabled;
|
||||
|
||||
/**
|
||||
* IME open states the mOpen value of SetInputContext() should be one value of
|
||||
@ -336,22 +334,24 @@ struct IMEState final {
|
||||
};
|
||||
Open mOpen;
|
||||
|
||||
IMEState() : mEnabled(ENABLED), mOpen(DONT_CHANGE_OPEN_STATE) {}
|
||||
IMEState() : mEnabled(IMEEnabled::Enabled), mOpen(DONT_CHANGE_OPEN_STATE) {}
|
||||
|
||||
explicit IMEState(Enabled aEnabled, Open aOpen = DONT_CHANGE_OPEN_STATE)
|
||||
explicit IMEState(IMEEnabled aEnabled, Open aOpen = DONT_CHANGE_OPEN_STATE)
|
||||
: mEnabled(aEnabled), mOpen(aOpen) {}
|
||||
|
||||
// Returns true if the user can input characters.
|
||||
// This means that a plain text editor, an HTML editor, a password editor or
|
||||
// a plain text editor whose ime-mode is "disabled".
|
||||
bool IsEditable() const {
|
||||
return mEnabled == ENABLED || mEnabled == PASSWORD;
|
||||
return mEnabled == IMEEnabled::Enabled || mEnabled == IMEEnabled::Password;
|
||||
}
|
||||
// Returns true if the user might be able to input characters.
|
||||
// This means that a plain text editor, an HTML editor, a password editor,
|
||||
// a plain text editor whose ime-mode is "disabled" or a windowless plugin
|
||||
// has focus.
|
||||
bool MaybeEditable() const { return IsEditable() || mEnabled == PLUGIN; }
|
||||
bool MaybeEditable() const {
|
||||
return IsEditable() || mEnabled == IMEEnabled::Plugin;
|
||||
}
|
||||
};
|
||||
|
||||
// NS_ONLY_ONE_NATIVE_IME_CONTEXT is a special value of native IME context.
|
||||
@ -980,8 +980,7 @@ struct CandidateWindowPosition {
|
||||
bool mExcludeRect;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const IMEState::Enabled& aEnabled);
|
||||
std::ostream& operator<<(std::ostream& aStream, const IMEEnabled& aEnabled);
|
||||
std::ostream& operator<<(std::ostream& aStream, const IMEState::Open& aOpen);
|
||||
std::ostream& operator<<(std::ostream& aStream, const IMEState& aState);
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
|
@ -94,7 +94,7 @@ PuppetWidget::PuppetWidget(BrowserChild* aBrowserChild)
|
||||
mNeedIMEStateInit(false),
|
||||
mIgnoreCompositionEvents(false) {
|
||||
// Setting 'Unknown' means "not yet cached".
|
||||
mInputContext.mIMEState.mEnabled = IMEState::UNKNOWN;
|
||||
mInputContext.mIMEState.mEnabled = IMEEnabled::Unknown;
|
||||
}
|
||||
|
||||
PuppetWidget::~PuppetWidget() { Destroy(); }
|
||||
@ -696,7 +696,7 @@ void PuppetWidget::DefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent) {
|
||||
// When this widget caches input context and currently managed by
|
||||
// IMEStateManager, the cache is valid.
|
||||
bool PuppetWidget::HaveValidInputContextCache() const {
|
||||
return (mInputContext.mIMEState.mEnabled != IMEState::UNKNOWN &&
|
||||
return (mInputContext.mIMEState.mEnabled != IMEEnabled::Unknown &&
|
||||
IMEStateManager::GetWidgetForActiveInputContext() == this);
|
||||
}
|
||||
|
||||
@ -761,7 +761,7 @@ nsresult PuppetWidget::NotifyIMEOfFocusChange(
|
||||
|
||||
bool gotFocus = aIMENotification.mMessage == NOTIFY_IME_OF_FOCUS;
|
||||
if (gotFocus) {
|
||||
if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN) {
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin) {
|
||||
// When IME gets focus, we should initalize all information of the
|
||||
// content.
|
||||
if (NS_WARN_IF(!mContentCache.CacheAll(this, &aIMENotification))) {
|
||||
@ -807,7 +807,7 @@ nsresult PuppetWidget::NotifyIMEOfCompositionUpdate(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin &&
|
||||
NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -827,7 +827,7 @@ nsresult PuppetWidget::NotifyIMEOfTextChange(
|
||||
}
|
||||
|
||||
// While a plugin has focus, text change notification shouldn't be available.
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEState::PLUGIN)) {
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ nsresult PuppetWidget::NotifyIMEOfSelectionChange(
|
||||
|
||||
// While a plugin has focus, selection change notification shouldn't be
|
||||
// available.
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEState::PLUGIN)) {
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -886,7 +886,7 @@ nsresult PuppetWidget::NotifyIMEOfMouseButtonEvent(
|
||||
|
||||
// While a plugin has focus, mouse button event notification shouldn't be
|
||||
// available.
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEState::PLUGIN)) {
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -911,7 +911,7 @@ nsresult PuppetWidget::NotifyIMEOfPositionChange(
|
||||
}
|
||||
// While a plugin has focus, selection range isn't available. So, we don't
|
||||
// need to cache it at that time.
|
||||
if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin &&
|
||||
NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1233,8 +1233,8 @@ void PuppetWidget::EnableIMEForPlugin(bool aEnable) {
|
||||
|
||||
// If current IME state isn't plugin, we ignore this call.
|
||||
if (NS_WARN_IF(HaveValidInputContextCache() &&
|
||||
mInputContext.mIMEState.mEnabled != IMEState::UNKNOWN &&
|
||||
mInputContext.mIMEState.mEnabled != IMEState::PLUGIN)) {
|
||||
mInputContext.mIMEState.mEnabled != IMEEnabled::Unknown &&
|
||||
mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1350,7 +1350,7 @@ PuppetWidget::NotifyIME(TextEventDispatcher* aTextEventDispatcher,
|
||||
|
||||
NS_IMETHODIMP_(IMENotificationRequests)
|
||||
PuppetWidget::GetIMENotificationRequests() {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
// If a plugin has focus, we cannot receive text nor selection change
|
||||
// in the plugin. Therefore, PuppetWidget needs to receive only position
|
||||
// change event for updating the editor rect cache.
|
||||
|
@ -1429,7 +1429,7 @@ void GeckoEditableSupport::SetInputContext(const InputContext& aContext,
|
||||
|
||||
mInputContext = aContext;
|
||||
|
||||
if (mInputContext.mIMEState.mEnabled != IMEState::DISABLED &&
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Disabled &&
|
||||
!mInputContext.mHTMLInputInputmode.EqualsLiteral("none") &&
|
||||
aAction.UserMightRequestOpenVKB()) {
|
||||
// Don't reset keyboard when we should simply open the vkb
|
||||
@ -1457,16 +1457,16 @@ void GeckoEditableSupport::NotifyIMEContext(const InputContext& aContext,
|
||||
const bool isUserAction =
|
||||
aAction.mCause != InputContextAction::CAUSE_LONGPRESS &&
|
||||
!(aAction.mCause == InputContextAction::CAUSE_UNKNOWN_CHROME &&
|
||||
aContext.mIMEState.mEnabled == IMEState::ENABLED) &&
|
||||
aContext.mIMEState.mEnabled == IMEEnabled::Enabled) &&
|
||||
(aAction.IsHandlingUserInput() || aContext.mHasHandledUserInput);
|
||||
const int32_t flags =
|
||||
(inPrivateBrowsing ? EditableListener::IME_FLAG_PRIVATE_BROWSING : 0) |
|
||||
(isUserAction ? EditableListener::IME_FLAG_USER_ACTION : 0);
|
||||
|
||||
mEditable->NotifyIMEContext(
|
||||
aContext.mIMEState.mEnabled, aContext.mHTMLInputType,
|
||||
aContext.mHTMLInputInputmode, aContext.mActionHint,
|
||||
aContext.mAutocapitalize, flags);
|
||||
static_cast<int32_t>(aContext.mIMEState.mEnabled),
|
||||
aContext.mHTMLInputType, aContext.mHTMLInputInputmode,
|
||||
aContext.mActionHint, aContext.mAutocapitalize, flags);
|
||||
}
|
||||
|
||||
InputContext GeckoEditableSupport::GetInputContext() {
|
||||
|
@ -2322,8 +2322,8 @@ void TextInputHandler::InsertText(NSAttributedString* aAttrString, NSRange* aRep
|
||||
currentKeyEvent ? TrueOrFalse(currentKeyEvent->mCompositionDispatched) : "N/A"));
|
||||
|
||||
InputContext context = mWidget->GetInputContext();
|
||||
bool isEditable = (context.mIMEState.mEnabled == IMEState::ENABLED ||
|
||||
context.mIMEState.mEnabled == IMEState::PASSWORD);
|
||||
bool isEditable = (context.mIMEState.mEnabled == IMEEnabled::Enabled ||
|
||||
context.mIMEState.mEnabled == IMEEnabled::Password);
|
||||
NSRange selectedRange = SelectedRange();
|
||||
|
||||
nsAutoString str;
|
||||
|
@ -1525,19 +1525,19 @@ void nsChildView::SetInputContext(const InputContext& aContext, const InputConte
|
||||
// IMEInputHandler::IsEditableContent() too.
|
||||
mInputContext = aContext;
|
||||
switch (aContext.mIMEState.mEnabled) {
|
||||
case IMEState::ENABLED:
|
||||
case IMEState::PLUGIN:
|
||||
case IMEEnabled::Enabled:
|
||||
case IMEEnabled::Plugin:
|
||||
mTextInputHandler->SetASCIICapableOnly(false);
|
||||
mTextInputHandler->EnableIME(true);
|
||||
if (mInputContext.mIMEState.mOpen != IMEState::DONT_CHANGE_OPEN_STATE) {
|
||||
mTextInputHandler->SetIMEOpenState(mInputContext.mIMEState.mOpen == IMEState::OPEN);
|
||||
}
|
||||
break;
|
||||
case IMEState::DISABLED:
|
||||
case IMEEnabled::Disabled:
|
||||
mTextInputHandler->SetASCIICapableOnly(false);
|
||||
mTextInputHandler->EnableIME(false);
|
||||
break;
|
||||
case IMEState::PASSWORD:
|
||||
case IMEEnabled::Password:
|
||||
mTextInputHandler->SetASCIICapableOnly(true);
|
||||
mTextInputHandler->EnableIME(false);
|
||||
break;
|
||||
@ -1548,8 +1548,8 @@ void nsChildView::SetInputContext(const InputContext& aContext, const InputConte
|
||||
|
||||
InputContext nsChildView::GetInputContext() {
|
||||
switch (mInputContext.mIMEState.mEnabled) {
|
||||
case IMEState::ENABLED:
|
||||
case IMEState::PLUGIN:
|
||||
case IMEEnabled::Enabled:
|
||||
case IMEEnabled::Plugin:
|
||||
if (mTextInputHandler) {
|
||||
mInputContext.mIMEState.mOpen =
|
||||
mTextInputHandler->IsIMEOpened() ? IMEState::OPEN : IMEState::CLOSED;
|
||||
|
@ -30,21 +30,6 @@ static inline const char* ToChar(bool aBool) {
|
||||
return aBool ? "true" : "false";
|
||||
}
|
||||
|
||||
static const char* GetEnabledStateName(uint32_t aState) {
|
||||
switch (aState) {
|
||||
case IMEState::DISABLED:
|
||||
return "DISABLED";
|
||||
case IMEState::ENABLED:
|
||||
return "ENABLED";
|
||||
case IMEState::PASSWORD:
|
||||
return "PASSWORD";
|
||||
case IMEState::PLUGIN:
|
||||
return "PLUG_IN";
|
||||
default:
|
||||
return "UNKNOWN ENABLED STATUS!!";
|
||||
}
|
||||
}
|
||||
|
||||
static const char* GetEventType(GdkEventKey* aKeyEvent) {
|
||||
switch (aKeyEvent->type) {
|
||||
case GDK_KEY_PRESS:
|
||||
@ -632,7 +617,7 @@ NS_IMETHODIMP_(IMENotificationRequests)
|
||||
IMContextWrapper::GetIMENotificationRequests() {
|
||||
// While a plugin has focus, IMContextWrapper doesn't need any
|
||||
// notifications.
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
return IMENotificationRequests();
|
||||
}
|
||||
|
||||
@ -706,7 +691,7 @@ void IMContextWrapper::OnDestroyWindow(nsWindow* aWindow) {
|
||||
|
||||
mOwnerWindow = nullptr;
|
||||
mLastFocusedWindow = nullptr;
|
||||
mInputContext.mIMEState.mEnabled = IMEState::DISABLED;
|
||||
mInputContext.mIMEState.mEnabled = IMEEnabled::Disabled;
|
||||
mPostingKeyEvents.Clear();
|
||||
|
||||
MOZ_LOG(gGtkIMLog, LogLevel::Debug,
|
||||
@ -922,7 +907,7 @@ KeyHandlingState IMContextWrapper::OnKeyEvent(
|
||||
// <input type="password"> or |ime-mode: disabled;|. However, in
|
||||
// some environments, not so actually. Therefore, we need to check
|
||||
// the result of gtk_im_context_filter_keypress() later.
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Password) {
|
||||
probablyHandledAsynchronously = false;
|
||||
maybeHandledAsynchronously = !isHandlingAsyncEvent;
|
||||
break;
|
||||
@ -1266,7 +1251,7 @@ void IMContextWrapper::SetInputContext(nsWindow* aCaller,
|
||||
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
||||
("0x%p SetInputContext(aCaller=0x%p, aContext={ mIMEState={ "
|
||||
"mEnabled=%s }, mHTMLInputType=%s })",
|
||||
this, aCaller, GetEnabledStateName(aContext->mIMEState.mEnabled),
|
||||
this, aCaller, ToString(aContext->mIMEState.mEnabled).c_str(),
|
||||
NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get()));
|
||||
|
||||
if (aCaller != mLastFocusedWindow) {
|
||||
@ -1330,7 +1315,7 @@ void IMContextWrapper::SetInputContext(nsWindow* aCaller,
|
||||
// I.e., let's ignore tablet devices for now. When somebody
|
||||
// reports actual trouble on tablet devices, we should try to
|
||||
// look for a way to solve actual problem.
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Password) {
|
||||
purpose = GTK_INPUT_PURPOSE_PASSWORD;
|
||||
} else if (inputType.EqualsLiteral("email")) {
|
||||
purpose = GTK_INPUT_PURPOSE_EMAIL;
|
||||
@ -1393,7 +1378,7 @@ GtkIMContext* IMContextWrapper::GetCurrentContext() const {
|
||||
if (IsEnabled()) {
|
||||
return mContext;
|
||||
}
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Password) {
|
||||
return mSimpleContext;
|
||||
}
|
||||
return mDummyContext;
|
||||
@ -1408,10 +1393,10 @@ bool IMContextWrapper::IsValidContext(GtkIMContext* aContext) const {
|
||||
}
|
||||
|
||||
bool IMContextWrapper::IsEnabled() const {
|
||||
return mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
|
||||
mInputContext.mIMEState.mEnabled == IMEState::PLUGIN ||
|
||||
return mInputContext.mIMEState.mEnabled == IMEEnabled::Enabled ||
|
||||
mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin ||
|
||||
(!sUseSimpleContext &&
|
||||
mInputContext.mIMEState.mEnabled == IMEState::PASSWORD);
|
||||
mInputContext.mIMEState.mEnabled == IMEEnabled::Password);
|
||||
}
|
||||
|
||||
void IMContextWrapper::Focus() {
|
||||
|
@ -7202,7 +7202,7 @@ void nsWindow::SetInputContext(const InputContext& aContext,
|
||||
InputContext nsWindow::GetInputContext() {
|
||||
InputContext context;
|
||||
if (!mIMContext) {
|
||||
context.mIMEState.mEnabled = IMEState::DISABLED;
|
||||
context.mIMEState.mEnabled = IMEEnabled::Disabled;
|
||||
context.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
|
||||
} else {
|
||||
context = mIMContext->GetInputContext();
|
||||
|
@ -844,10 +844,10 @@ struct ParamTraits<mozilla::widget::IMENotification> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::widget::IMEState::Enabled>
|
||||
: ContiguousEnumSerializer<mozilla::widget::IMEState::Enabled,
|
||||
mozilla::widget::IMEState::Enabled::DISABLED,
|
||||
mozilla::widget::IMEState::Enabled::UNKNOWN> {};
|
||||
struct ParamTraits<mozilla::widget::IMEEnabled>
|
||||
: ContiguousEnumSerializer<mozilla::widget::IMEEnabled,
|
||||
mozilla::widget::IMEEnabled::Disabled,
|
||||
mozilla::widget::IMEEnabled::Unknown> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::widget::IMEState::Open>
|
||||
|
@ -378,6 +378,7 @@ class nsIWidget : public nsISupports {
|
||||
typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild;
|
||||
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
|
||||
typedef mozilla::layers::ZoomConstraints ZoomConstraints;
|
||||
typedef mozilla::widget::IMEEnabled IMEEnabled;
|
||||
typedef mozilla::widget::IMEMessage IMEMessage;
|
||||
typedef mozilla::widget::IMENotification IMENotification;
|
||||
typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
|
||||
@ -1864,7 +1865,7 @@ class nsIWidget : public nsISupports {
|
||||
* Tell the plugin has focus. It is unnecessary to use IPC
|
||||
*/
|
||||
bool PluginHasFocus() {
|
||||
return GetInputContext().mIMEState.mEnabled == IMEState::PLUGIN;
|
||||
return GetInputContext().mIMEState.mEnabled == IMEEnabled::Plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2098,7 +2098,7 @@ nsEventStatus NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
|
||||
void NativeKey::MaybeInitPluginEventOfKeyEvent(
|
||||
WidgetKeyboardEvent& aKeyEvent, const MSG& aMsgSentToPlugin) const {
|
||||
if (mWidget->GetInputContext().mIMEState.mEnabled != IMEState::PLUGIN) {
|
||||
if (mWidget->GetInputContext().mIMEState.mEnabled != IMEEnabled::Plugin) {
|
||||
return;
|
||||
}
|
||||
NPEvent pluginEvent;
|
||||
|
@ -5780,7 +5780,7 @@ bool TSFTextStore::CreateAndSetFocus(nsWindowBase* aFocusedWidget,
|
||||
EnsureToDestroyAndReleaseEnabledTextStoreIf(textStore);
|
||||
return false;
|
||||
}
|
||||
if (aContext.mIMEState.mEnabled == IMEState::PASSWORD) {
|
||||
if (aContext.mIMEState.mEnabled == IMEEnabled::Password) {
|
||||
MarkContextAsKeyboardDisabled(textStore->mContext);
|
||||
RefPtr<ITfContext> topContext;
|
||||
newDocMgr->GetTop(getter_AddRefs(topContext));
|
||||
|
@ -435,7 +435,7 @@ void IMEHandler::SetInputContext(nsWindow* aWindow, InputContext& aInputContext,
|
||||
const InputContext& oldInputContext = aWindow->GetInputContext();
|
||||
|
||||
// Assume that SetInputContext() is called only when aWindow has focus.
|
||||
sPluginHasFocus = (aInputContext.mIMEState.mEnabled == IMEState::PLUGIN);
|
||||
sPluginHasFocus = (aInputContext.mIMEState.mEnabled == IMEEnabled::Plugin);
|
||||
if (sPluginHasFocus) {
|
||||
// Update some cached system settings in the plugin.
|
||||
aWindow->DispatchPluginSettingEvents();
|
||||
@ -460,7 +460,7 @@ void IMEHandler::SetInputContext(nsWindow* aWindow, InputContext& aInputContext,
|
||||
if (sIsIMMEnabled) {
|
||||
// Associate IMC with aWindow only when it's necessary.
|
||||
AssociateIMEContext(aWindow, enable && NeedsToAssociateIMC());
|
||||
} else if (oldInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
|
||||
} else if (oldInputContext.mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
// Disassociate the IME context from the window when plugin loses focus
|
||||
// in pure TSF mode.
|
||||
AssociateIMEContext(aWindow, false);
|
||||
@ -519,7 +519,7 @@ void IMEHandler::InitInputContext(nsWindow* aWindow,
|
||||
}
|
||||
|
||||
// For a11y, the default enabled state should be 'enabled'.
|
||||
aInputContext.mIMEState.mEnabled = IMEState::ENABLED;
|
||||
aInputContext.mIMEState.mEnabled = IMEEnabled::Enabled;
|
||||
|
||||
if (sIsInTSFMode) {
|
||||
TSFTextStore::SetInputContext(
|
||||
|
@ -1637,7 +1637,7 @@ bool WinUtils::IsIMEEnabled(const InputContext& aInputContext) {
|
||||
if (!IsIMEEnabled(aInputContext.mIMEState.mEnabled)) {
|
||||
return false;
|
||||
}
|
||||
if (aInputContext.mIMEState.mEnabled == IMEState::PLUGIN &&
|
||||
if (aInputContext.mIMEState.mEnabled == IMEEnabled::Plugin &&
|
||||
aInputContext.mHTMLInputType.EqualsLiteral("password")) {
|
||||
return false;
|
||||
}
|
||||
@ -1645,8 +1645,8 @@ bool WinUtils::IsIMEEnabled(const InputContext& aInputContext) {
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool WinUtils::IsIMEEnabled(IMEState::Enabled aIMEState) {
|
||||
return (aIMEState == IMEState::ENABLED || aIMEState == IMEState::PLUGIN);
|
||||
bool WinUtils::IsIMEEnabled(IMEEnabled aIMEState) {
|
||||
return (aIMEState == IMEEnabled::Enabled || aIMEState == IMEEnabled::Plugin);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -426,7 +426,7 @@ class WinUtils {
|
||||
* Returns true if the context or IME state is enabled. Otherwise, false.
|
||||
*/
|
||||
static bool IsIMEEnabled(const InputContext& aInputContext);
|
||||
static bool IsIMEEnabled(IMEState::Enabled aIMEState);
|
||||
static bool IsIMEEnabled(IMEEnabled aIMEState);
|
||||
|
||||
/**
|
||||
* Returns modifier key array for aModifiers. This is for
|
||||
|
@ -8633,7 +8633,7 @@ void nsWindow::DefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent) {
|
||||
|
||||
void nsWindow::EnableIMEForPlugin(bool aEnable) {
|
||||
// Current IME state isn't plugin, ignore this call
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled != IMEState::PLUGIN)) {
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user