зеркало из https://github.com/mozilla/gecko-dev.git
Bug 685395 part.3 Rename SetInputMode()/GetInputMode() to SetInputContext()/GetInputContext() and make SetInputContext() take the reason by a separated argument r=roc, sr=matspal
This commit is contained in:
Родитель
cbcebd2356
Коммит
97702be0bf
|
@ -40,7 +40,6 @@
|
|||
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupports.h"
|
||||
|
@ -90,7 +89,9 @@ nsIMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
|
|||
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
|
||||
if (widget) {
|
||||
PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
|
||||
SetIMEState(newState, nsnull, widget, InputContext::FOCUS_REMOVED);
|
||||
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
|
||||
InputContextAction::LOST_FOCUS);
|
||||
SetIMEState(newState, nsnull, widget, action);
|
||||
}
|
||||
sContent = nsnull;
|
||||
sPresContext = nsnull;
|
||||
|
@ -115,7 +116,9 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
|
|||
if (NS_FAILED(rv))
|
||||
widget->ResetInputState();
|
||||
PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
|
||||
SetIMEState(newState, nsnull, widget, InputContext::FOCUS_REMOVED);
|
||||
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
|
||||
InputContextAction::LOST_FOCUS);
|
||||
SetIMEState(newState, nsnull, widget, action);
|
||||
}
|
||||
|
||||
sContent = nsnull;
|
||||
|
@ -127,7 +130,16 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
|
|||
nsresult
|
||||
nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
PRUint32 aReason)
|
||||
InputContextAction::Cause aCause)
|
||||
{
|
||||
InputContextAction action(aCause);
|
||||
return OnChangeFocusInternal(aPresContext, aContent, action);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsIMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
InputContextAction aAction)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
|
||||
|
@ -168,16 +180,19 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
|
|||
// the enabled state isn't changing, we should do nothing.
|
||||
return NS_OK;
|
||||
}
|
||||
InputContext context;
|
||||
if (!widget || NS_FAILED(widget->GetInputMode(context))) {
|
||||
// this platform doesn't support IME controlling
|
||||
return NS_OK;
|
||||
}
|
||||
InputContext context = widget->GetInputContext();
|
||||
if (context.mIMEEnabled ==
|
||||
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) {
|
||||
// the enabled state isn't changing.
|
||||
return NS_OK;
|
||||
}
|
||||
aAction.mFocusChange = InputContextAction::FOCUS_NOT_CHANGED;
|
||||
} 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 & nsIContent::IME_STATUS_ENABLE);
|
||||
aAction.mFocusChange =
|
||||
gotFocus ? InputContextAction::GOT_FOCUS : InputContextAction::LOST_FOCUS;
|
||||
}
|
||||
|
||||
// Current IME transaction should commit
|
||||
|
@ -193,7 +208,7 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
|
|||
|
||||
if (newState != nsIContent::IME_STATUS_NONE) {
|
||||
// Update IME state for new focus widget
|
||||
SetIMEState(newState, aContent, widget, aReason);
|
||||
SetIMEState(newState, aContent, widget, aAction);
|
||||
}
|
||||
|
||||
sPresContext = aPresContext;
|
||||
|
@ -207,9 +222,10 @@ nsIMEStateManager::OnInstalledMenuKeyboardListener(bool aInstalling)
|
|||
{
|
||||
sInstalledMenuKeyboardListener = aInstalling;
|
||||
|
||||
PRUint32 reason = aInstalling ? InputContext::FOCUS_MOVED_TO_MENU
|
||||
: InputContext::FOCUS_MOVED_FROM_MENU;
|
||||
OnChangeFocus(sPresContext, sContent, reason);
|
||||
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
|
||||
aInstalling ? InputContextAction::MENU_GOT_PSEUDO_FOCUS :
|
||||
InputContextAction::MENU_LOST_PSEUDO_FOCUS);
|
||||
OnChangeFocusInternal(sPresContext, sContent, action);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -227,11 +243,7 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
|
|||
}
|
||||
|
||||
// Don't update IME state when enabled state isn't actually changed.
|
||||
InputContext context;
|
||||
nsresult rv = widget->GetInputMode(context);
|
||||
if (NS_FAILED(rv)) {
|
||||
return; // This platform doesn't support controling the IME state.
|
||||
}
|
||||
InputContext context = widget->GetInputContext();
|
||||
PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED;
|
||||
if (context.mIMEEnabled ==
|
||||
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) {
|
||||
|
@ -241,8 +253,9 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
|
|||
// commit current composition
|
||||
widget->ResetInputState();
|
||||
|
||||
SetIMEState(aNewIMEState, aContent, widget,
|
||||
InputContext::EDITOR_STATE_MODIFIED);
|
||||
InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
|
||||
InputContextAction::FOCUS_NOT_CHANGED);
|
||||
SetIMEState(aNewIMEState, aContent, widget, action);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
|
@ -296,7 +309,7 @@ void
|
|||
nsIMEStateManager::SetIMEState(PRUint32 aState,
|
||||
nsIContent* aContent,
|
||||
nsIWidget* aWidget,
|
||||
PRUint32 aReason)
|
||||
InputContextAction aAction)
|
||||
{
|
||||
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
|
||||
if (!aWidget)
|
||||
|
@ -305,7 +318,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
|
|||
PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
|
||||
InputContext context;
|
||||
context.mIMEEnabled = state;
|
||||
|
||||
|
||||
if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
|
||||
(aContent->Tag() == nsGkAtoms::input ||
|
||||
aContent->Tag() == nsGkAtoms::textarea)) {
|
||||
|
@ -339,13 +352,14 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
|
|||
}
|
||||
}
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
context.mReason = aReason | InputContext::FOCUS_FROM_CONTENT_PROCESS;
|
||||
} else {
|
||||
context.mReason = aReason;
|
||||
// XXX I think that we should use nsContentUtils::IsCallerChrome() instead
|
||||
// of the process type.
|
||||
if (aAction.mCause == InputContextAction::CAUSE_UNKNOWN &&
|
||||
XRE_GetProcessType() != GeckoProcessType_Content) {
|
||||
aAction.mCause = InputContextAction::CAUSE_UNKNOWN_CHROME;
|
||||
}
|
||||
|
||||
aWidget->SetInputMode(context);
|
||||
aWidget->SetInputContext(context, aAction);
|
||||
|
||||
nsContentUtils::AddScriptRunner(new IMEEnabledStateChangedEvent(state));
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
#define nsIMEStateManager_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsPIDOMWindow;
|
||||
class nsPresContext;
|
||||
class nsIWidget;
|
||||
class nsTextStateManager;
|
||||
class nsISelection;
|
||||
|
||||
|
@ -54,13 +54,22 @@ class nsISelection;
|
|||
|
||||
class nsIMEStateManager
|
||||
{
|
||||
protected:
|
||||
typedef mozilla::widget::InputContext InputContext;
|
||||
typedef mozilla::widget::InputContextAction InputContextAction;
|
||||
|
||||
public:
|
||||
static nsresult OnDestroyPresContext(nsPresContext* aPresContext);
|
||||
static nsresult OnRemoveContent(nsPresContext* aPresContext,
|
||||
nsIContent* aContent);
|
||||
/**
|
||||
* OnChangeFocus() should be called when focused content is changed or
|
||||
* IME enabled state is changed. If focus isn't actually changed and IME
|
||||
* enabled state isn't changed, this will do nothing.
|
||||
*/
|
||||
static nsresult OnChangeFocus(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
PRUint32 aReason);
|
||||
InputContextAction::Cause aCause);
|
||||
static void OnInstalledMenuKeyboardListener(bool aInstalling);
|
||||
|
||||
// These two methods manage focus and selection/text observers.
|
||||
|
@ -90,8 +99,12 @@ public:
|
|||
static void UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
static nsresult OnChangeFocusInternal(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
InputContextAction aAction);
|
||||
static void SetIMEState(PRUint32 aState, nsIContent* aContent,
|
||||
nsIWidget* aWidget, PRUint32 aReason);
|
||||
nsIWidget* aWidget,
|
||||
InputContextAction aAction);
|
||||
static PRUint32 GetNewIMEState(nsPresContext* aPresContext,
|
||||
nsIContent* aContent);
|
||||
|
||||
|
|
|
@ -1040,9 +1040,7 @@ nsDOMWindowUtils::GetIMEIsOpen(bool *aState)
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Open state should not be available when IME is not enabled.
|
||||
InputContext context;
|
||||
nsresult rv = widget->GetInputMode(context);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
InputContext context = widget->GetInputContext();
|
||||
if (context.mIMEEnabled != InputContext::IME_ENABLED) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -1059,10 +1057,7 @@ nsDOMWindowUtils::GetIMEStatus(PRUint32 *aState)
|
|||
if (!widget)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
InputContext context;
|
||||
nsresult rv = widget->GetInputMode(context);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
InputContext context = widget->GetInputContext();
|
||||
*aState = context.mIMEEnabled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1077,10 +1072,7 @@ nsDOMWindowUtils::GetFocusedInputType(char** aType)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
InputContext context;
|
||||
nsresult rv = widget->GetInputMode(context);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
InputContext context = widget->GetInputContext();
|
||||
*aType = ToNewCString(context.mHTMLInputType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
#include "nsIMEStateManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsCaret.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsFrameSelection.h"
|
||||
|
@ -338,19 +337,15 @@ nsFocusManager::GetRedirectedFocus(nsIContent* aContent)
|
|||
}
|
||||
|
||||
// static
|
||||
PRUint32
|
||||
nsFocusManager::GetFocusMoveReason(PRUint32 aFlags)
|
||||
InputContextAction::Cause
|
||||
nsFocusManager::GetFocusMoveActionCause(PRUint32 aFlags)
|
||||
{
|
||||
PRUint32 reason = InputContext::FOCUS_MOVED_UNKNOWN;
|
||||
if (aFlags & nsIFocusManager::FLAG_BYMOUSE) {
|
||||
reason = InputContext::FOCUS_MOVED_BY_MOUSE;
|
||||
return InputContextAction::CAUSE_MOUSE;
|
||||
} else if (aFlags & nsIFocusManager::FLAG_BYKEY) {
|
||||
reason = InputContext::FOCUS_MOVED_BY_KEY;
|
||||
} else if (aFlags & nsIFocusManager::FLAG_BYMOVEFOCUS) {
|
||||
reason = InputContext::FOCUS_MOVED_BY_MOVEFOCUS;
|
||||
return InputContextAction::CAUSE_KEY;
|
||||
}
|
||||
|
||||
return reason;
|
||||
return InputContextAction::CAUSE_UNKNOWN;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -966,7 +961,7 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow)
|
|||
nsIMEStateManager::OnTextStateBlur(nsnull, nsnull);
|
||||
if (presShell) {
|
||||
nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull,
|
||||
InputContext::FOCUS_REMOVED);
|
||||
GetFocusMoveActionCause(0));
|
||||
SetCaretVisible(presShell, false, nsnull);
|
||||
}
|
||||
|
||||
|
@ -1527,7 +1522,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
|
|||
nsIMEStateManager::OnTextStateBlur(nsnull, nsnull);
|
||||
if (mActiveWindow) {
|
||||
nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull,
|
||||
InputContext::FOCUS_REMOVED);
|
||||
GetFocusMoveActionCause(0));
|
||||
}
|
||||
|
||||
// now adjust the actual focus, by clearing the fields in the focus manager
|
||||
|
@ -1790,8 +1785,8 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||
}
|
||||
}
|
||||
|
||||
PRUint32 reason = GetFocusMoveReason(aFlags);
|
||||
nsIMEStateManager::OnChangeFocus(presContext, aContent, reason);
|
||||
nsIMEStateManager::OnChangeFocus(presContext, aContent,
|
||||
GetFocusMoveActionCause(aFlags));
|
||||
|
||||
// as long as this focus wasn't because a window was raised, update the
|
||||
// commands
|
||||
|
@ -1808,7 +1803,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||
} else {
|
||||
nsIMEStateManager::OnTextStateBlur(presContext, nsnull);
|
||||
nsIMEStateManager::OnChangeFocus(presContext, nsnull,
|
||||
InputContext::FOCUS_REMOVED);
|
||||
GetFocusMoveActionCause(aFlags));
|
||||
if (!aWindowRaised) {
|
||||
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"));
|
||||
}
|
||||
|
@ -1832,7 +1827,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
|||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
nsIMEStateManager::OnTextStateBlur(presContext, nsnull);
|
||||
nsIMEStateManager::OnChangeFocus(presContext, nsnull,
|
||||
InputContext::FOCUS_REMOVED);
|
||||
GetFocusMoveActionCause(aFlags));
|
||||
|
||||
if (!aWindowRaised)
|
||||
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"));
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsWeakReference.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#define FOCUSMETHOD_MASK 0xF000
|
||||
#define FOCUSMETHODANDRING_MASK 0xF0F000
|
||||
|
@ -67,6 +68,8 @@ class nsFocusManager : public nsIFocusManager,
|
|||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
typedef mozilla::widget::InputContextAction InputContextAction;
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFocusManager, nsIFocusManager)
|
||||
|
@ -131,11 +134,9 @@ public:
|
|||
static nsIContent* GetRedirectedFocus(nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* Returns a flag indicating the source and/or reason of the focus change.
|
||||
* This is used to indicate to the IME code if the focus come from a user
|
||||
* input or a script for example.
|
||||
* Returns an InputContextAction cause for aFlags.
|
||||
*/
|
||||
static PRUint32 GetFocusMoveReason(PRUint32 aFlags);
|
||||
static InputContextAction::Cause GetFocusMoveActionCause(PRUint32 aFlags);
|
||||
|
||||
static bool sMouseFocusesFormControl;
|
||||
|
||||
|
|
|
@ -172,9 +172,13 @@ parent:
|
|||
*/
|
||||
sync EndIMEComposition(bool cancel) returns (nsString composition);
|
||||
|
||||
sync GetIMEEnabled() returns (PRUint32 value);
|
||||
sync GetInputContext() returns (PRUint32 value);
|
||||
|
||||
SetInputMode(PRUint32 value, nsString type, nsString actionHint, PRUint32 reason);
|
||||
SetInputContext(PRUint32 value,
|
||||
nsString type,
|
||||
nsString actionHint,
|
||||
PRInt32 cause,
|
||||
PRInt32 focusChange);
|
||||
|
||||
sync GetIMEOpenState() returns (bool value);
|
||||
|
||||
|
|
|
@ -564,7 +564,7 @@ TabParent::RecvEndIMEComposition(const bool& aCancel,
|
|||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvGetIMEEnabled(PRUint32* aValue)
|
||||
TabParent::RecvGetInputContext(PRUint32* aValue)
|
||||
{
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
if (!widget) {
|
||||
|
@ -572,14 +572,17 @@ TabParent::RecvGetIMEEnabled(PRUint32* aValue)
|
|||
return true;
|
||||
}
|
||||
|
||||
InputContext context;
|
||||
widget->GetInputMode(context);
|
||||
InputContext context = widget->GetInputContext();
|
||||
*aValue = context.mIMEEnabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvSetInputMode(const PRUint32& aValue, const nsString& aType, const nsString& aAction, const PRUint32& aReason)
|
||||
TabParent::RecvSetInputContext(const PRUint32& aValue,
|
||||
const nsString& aType,
|
||||
const nsString& aActionHint,
|
||||
const PRInt32& aCause,
|
||||
const PRInt32& aFocusChange)
|
||||
{
|
||||
// mIMETabParent (which is actually static) tracks which if any TabParent has IMEFocus
|
||||
// When the input mode is set to anything but IME_STATUS_NONE, mIMETabParent should be set to this
|
||||
|
@ -591,9 +594,11 @@ TabParent::RecvSetInputMode(const PRUint32& aValue, const nsString& aType, const
|
|||
InputContext context;
|
||||
context.mIMEEnabled = aValue;
|
||||
context.mHTMLInputType.Assign(aType);
|
||||
context.mActionHint.Assign(aAction);
|
||||
context.mReason = aReason;
|
||||
widget->SetInputMode(context);
|
||||
context.mActionHint.Assign(aActionHint);
|
||||
InputContextAction action(
|
||||
static_cast<InputContextAction::Cause>(aCause),
|
||||
static_cast<InputContextAction::FocusChange>(aFocusChange));
|
||||
widget->SetInputContext(context, action);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
||||
if (!observerService)
|
||||
|
|
|
@ -103,8 +103,12 @@ public:
|
|||
virtual bool RecvNotifyIMETextHint(const nsString& aText);
|
||||
virtual bool RecvEndIMEComposition(const bool& aCancel,
|
||||
nsString* aComposition);
|
||||
virtual bool RecvGetIMEEnabled(PRUint32* aValue);
|
||||
virtual bool RecvSetInputMode(const PRUint32& aValue, const nsString& aType, const nsString& aAction, const PRUint32& aReason);
|
||||
virtual bool RecvGetInputContext(PRUint32* aValue);
|
||||
virtual bool RecvSetInputContext(const PRUint32& aValue,
|
||||
const nsString& aType,
|
||||
const nsString& aActionHint,
|
||||
const PRInt32& aCause,
|
||||
const PRInt32& aFocusChange);
|
||||
virtual bool RecvGetIMEOpenState(bool* aValue);
|
||||
virtual bool RecvSetIMEOpenState(const bool& aValue);
|
||||
virtual bool RecvSetCursor(const PRUint32& aValue);
|
||||
|
|
|
@ -118,8 +118,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
|
|||
#endif
|
||||
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0x7db4261e, 0xf356, 0x45a1, \
|
||||
{ 0xb2, 0xc1, 0xf0, 0x85, 0xea, 0x93, 0xb3, 0xb4 } }
|
||||
{ 0xb4fa00ae, 0x913c, 0x42b1, \
|
||||
{ 0x93, 0xc8, 0x41, 0x57, 0x1e, 0x3d, 0x94, 0x99 } }
|
||||
|
||||
/*
|
||||
* Window shadow styles
|
||||
|
@ -237,12 +237,12 @@ namespace widget {
|
|||
|
||||
struct InputContext {
|
||||
/**
|
||||
* IME enabled states, the mIMEEnabled value of SetInputMode()/GetInputMode()
|
||||
* should be one value of following values.
|
||||
* IME enabled states, the mIMEEnabled value of
|
||||
* SetInputContext()/GetInputContext() should be one value of following
|
||||
* values.
|
||||
*
|
||||
* WARNING: If you change these values, you also need to edit:
|
||||
* nsIDOMWindowUtils.idl
|
||||
* nsDOMWindowUtils::SetIMEEnabled
|
||||
* nsContentUtils::GetWidgetStatusFromIMEStatus
|
||||
*/
|
||||
enum {
|
||||
|
@ -277,34 +277,67 @@ struct InputContext {
|
|||
|
||||
PRUint32 mIMEEnabled;
|
||||
|
||||
/* Does the change come from a trusted source */
|
||||
enum {
|
||||
FOCUS_REMOVED = 0x0001,
|
||||
FOCUS_MOVED_UNKNOWN = 0x0002,
|
||||
FOCUS_MOVED_BY_MOVEFOCUS = 0x0004,
|
||||
FOCUS_MOVED_BY_MOUSE = 0x0008,
|
||||
FOCUS_MOVED_BY_KEY = 0x0010,
|
||||
FOCUS_MOVED_TO_MENU = 0x0020,
|
||||
FOCUS_MOVED_FROM_MENU = 0x0040,
|
||||
EDITOR_STATE_MODIFIED = 0x0080,
|
||||
FOCUS_FROM_CONTENT_PROCESS = 0x0100
|
||||
};
|
||||
|
||||
bool FocusMovedByUser() const {
|
||||
return (mReason & FOCUS_MOVED_BY_MOUSE) || (mReason & FOCUS_MOVED_BY_KEY);
|
||||
};
|
||||
|
||||
bool FocusMovedInContentProcess() const {
|
||||
return (mReason & FOCUS_FROM_CONTENT_PROCESS);
|
||||
};
|
||||
|
||||
PRUint32 mReason;
|
||||
|
||||
/* The type of the input if the input is a html input field */
|
||||
nsString mHTMLInputType;
|
||||
|
||||
/* A hint for the action that is performed when the input is submitted */
|
||||
nsString mActionHint;
|
||||
|
||||
InputContext() : mIMEEnabled(IME_ENABLED) {}
|
||||
};
|
||||
|
||||
struct InputContextAction {
|
||||
/**
|
||||
* mCause indicates what action causes calling nsIWidget::SetInputContext().
|
||||
* It must be one of following values.
|
||||
*/
|
||||
enum Cause {
|
||||
// The cause is unknown but originated from content. Focus might have been
|
||||
// changed by content script.
|
||||
CAUSE_UNKNOWN,
|
||||
// The cause is unknown but originated from chrome. Focus might have been
|
||||
// changed by chrome script.
|
||||
CAUSE_UNKNOWN_CHROME,
|
||||
// The cause is user's keyboard operation.
|
||||
CAUSE_KEY,
|
||||
// The cause is user's mouse operation.
|
||||
CAUSE_MOUSE
|
||||
};
|
||||
Cause mCause;
|
||||
|
||||
/**
|
||||
* mFocusChange indicates what happened for focus.
|
||||
*/
|
||||
enum FocusChange {
|
||||
FOCUS_NOT_CHANGED,
|
||||
// A content got focus.
|
||||
GOT_FOCUS,
|
||||
// Focused content lost focus.
|
||||
LOST_FOCUS,
|
||||
// Menu got pseudo focus that means focused content isn't changed but
|
||||
// keyboard events will be handled by menu.
|
||||
MENU_GOT_PSEUDO_FOCUS,
|
||||
// Menu lost pseudo focus that means focused content will handle keyboard
|
||||
// events.
|
||||
MENU_LOST_PSEUDO_FOCUS
|
||||
};
|
||||
FocusChange mFocusChange;
|
||||
|
||||
bool ContentGotFocusByTrustedCause() const {
|
||||
return (mFocusChange == GOT_FOCUS &&
|
||||
mCause != CAUSE_UNKNOWN);
|
||||
}
|
||||
|
||||
InputContextAction() :
|
||||
mCause(CAUSE_UNKNOWN), mFocusChange(FOCUS_NOT_CHANGED)
|
||||
{
|
||||
}
|
||||
|
||||
InputContextAction(Cause aCause,
|
||||
FocusChange aFocusChange = FOCUS_NOT_CHANGED) :
|
||||
mCause(aCause), mFocusChange(aFocusChange)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
@ -323,6 +356,7 @@ class nsIWidget : public nsISupports {
|
|||
typedef LayerManager::LayersBackend LayersBackend;
|
||||
typedef mozilla::layers::PLayersChild PLayersChild;
|
||||
typedef mozilla::widget::InputContext InputContext;
|
||||
typedef mozilla::widget::InputContextAction InputContextAction;
|
||||
|
||||
// Used in UpdateThemeGeometries.
|
||||
struct ThemeGeometry {
|
||||
|
@ -1312,18 +1346,15 @@ class nsIWidget : public nsISupports {
|
|||
NS_IMETHOD CancelIMEComposition() = 0;
|
||||
|
||||
/*
|
||||
* Notifies the IME if the input context changes.
|
||||
*
|
||||
* aContext cannot be null.
|
||||
* Set mIMEEnabled to 'Enabled' or 'Disabled' or 'Password' or 'Plugin'.
|
||||
* Notifies the input context changes.
|
||||
*/
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext) = 0;
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction) = 0;
|
||||
|
||||
/*
|
||||
* Get IME is 'Enabled' or 'Disabled' or 'Password' or 'Plugin' and
|
||||
* other input context
|
||||
* Get current input context.
|
||||
*/
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext) = 0;
|
||||
NS_IMETHOD_(InputContext) GetInputContext() = 0;
|
||||
|
||||
/**
|
||||
* Set accelerated rendering to 'True' or 'False'
|
||||
|
|
|
@ -2046,36 +2046,33 @@ nsWindow::ResetInputState()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::SetInputMode(const InputContext& aContext)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsWindow::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
ALOGIME("IME: SetInputMode: s=%d trusted=%d",
|
||||
aContext.mIMEEnabled, aContext.mReason);
|
||||
ALOGIME("IME: SetInputContext: s=%d action=0x%X, 0x%X",
|
||||
aContext.mIMEEnabled, aAction.mCause, aAction.mFocusChange);
|
||||
|
||||
mInputContext = aContext;
|
||||
|
||||
// Ensure that opening the virtual keyboard is allowed for this specific
|
||||
// InputContext depending on the content.ime.strict.policy pref
|
||||
if (aContext.mIMEEnabled != InputContext::IME_DISABLED &&
|
||||
aContext.mIMEEnabled != InputContext::IME_PLUGIN) {
|
||||
if (Preferences::GetBool("content.ime.strict_policy", false) &&
|
||||
!aContext.FocusMovedByUser() &&
|
||||
aContext.FocusMovedInContentProcess()) {
|
||||
return NS_OK;
|
||||
}
|
||||
aContext.mIMEEnabled != InputContext::IME_PLUGIN &&
|
||||
Preferences::GetBool("content.ime.strict_policy", false) &&
|
||||
!aAction.ContentGotFocusByTrustedCause()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AndroidBridge::NotifyIMEEnabled(int(aContext.mIMEEnabled),
|
||||
aContext.mHTMLInputType,
|
||||
aContext.mActionHint);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::GetInputMode(InputContext& aContext)
|
||||
NS_IMETHODIMP_(InputContext)
|
||||
nsWindow::GetInputContext()
|
||||
{
|
||||
aContext = mInputContext;
|
||||
return NS_OK;
|
||||
return mInputContext;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -155,8 +155,9 @@ public:
|
|||
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext);
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext);
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
NS_IMETHOD CancelIMEComposition();
|
||||
|
||||
NS_IMETHOD OnIMEFocusChange(bool aFocus);
|
||||
|
|
|
@ -448,8 +448,9 @@ public:
|
|||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD SetIMEOpenState(bool aState);
|
||||
NS_IMETHOD GetIMEOpenState(bool* aState);
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext);
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext);
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
NS_IMETHOD CancelIMEComposition();
|
||||
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode,
|
||||
bool* aLEDState);
|
||||
|
|
|
@ -1689,9 +1689,11 @@ NS_IMETHODIMP nsChildView::GetIMEOpenState(bool* aState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChildView::SetInputMode(const InputContext& aContext)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsChildView::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE);
|
||||
NS_ENSURE_TRUE(mTextInputHandler, );
|
||||
mInputContext = aContext;
|
||||
switch (aContext.mIMEEnabled) {
|
||||
case InputContext::IME_ENABLED:
|
||||
|
@ -1710,13 +1712,12 @@ NS_IMETHODIMP nsChildView::SetInputMode(const InputContext& aContext)
|
|||
default:
|
||||
NS_ERROR("not implemented!");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChildView::GetInputMode(InputContext& aContext)
|
||||
NS_IMETHODIMP_(InputContext)
|
||||
nsChildView::GetInputContext()
|
||||
{
|
||||
aContext = mInputContext;
|
||||
return NS_OK;
|
||||
return mInputContext;
|
||||
}
|
||||
|
||||
// Destruct and don't commit the IME composition string.
|
||||
|
|
|
@ -286,9 +286,16 @@ public:
|
|||
void SetMenuBar(nsMenuBarX* aMenuBar);
|
||||
nsMenuBarX *GetMenuBar();
|
||||
|
||||
// nsIKBStateControl interface
|
||||
NS_IMETHOD ResetInputState();
|
||||
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
mInputContext = aContext;
|
||||
}
|
||||
NS_IMETHOD_(InputContext) GetInputContext()
|
||||
{
|
||||
return mInputContext;
|
||||
}
|
||||
NS_IMETHOD BeginSecureKeyboardInput();
|
||||
NS_IMETHOD EndSecureKeyboardInput();
|
||||
|
||||
|
@ -336,6 +343,7 @@ protected:
|
|||
bool mModal;
|
||||
|
||||
PRInt32 mNumModalDescendents;
|
||||
InputContext mInputContext;
|
||||
};
|
||||
|
||||
#endif // nsCocoaWindow_h_
|
||||
|
|
|
@ -542,16 +542,18 @@ nsGtkIMModule::CancelIMEComposition(nsWindow* aCaller)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext)
|
||||
void
|
||||
nsGtkIMModule::SetInputContext(nsWindow* aCaller,
|
||||
const InputContext* aContext,
|
||||
const InputContextAction* aAction)
|
||||
{
|
||||
if (aContext->mIMEEnabled == mInputContext.mIMEEnabled ||
|
||||
NS_UNLIKELY(IsDestroyed())) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
|
||||
("GtkIMModule(%p): SetInputMode, aCaller=%p, aState=%s mHTMLInputType=%s",
|
||||
("GtkIMModule(%p): SetInputContext, aCaller=%p, aState=%s mHTMLInputType=%s",
|
||||
this, aCaller, GetEnabledStateName(aContext->mIMEEnabled),
|
||||
NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get()));
|
||||
|
||||
|
@ -559,13 +561,13 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext)
|
|||
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
|
||||
(" FAILED, the caller isn't focused window, mLastFocusedWindow=%p",
|
||||
mLastFocusedWindow));
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mContext) {
|
||||
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
|
||||
(" FAILED, there are no context"));
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -573,7 +575,7 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext)
|
|||
mInputContext = *aContext;
|
||||
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
|
||||
(" SUCCEEDED, but we're not active"));
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// Release current IME focus if IME is enabled.
|
||||
|
@ -597,14 +599,10 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext)
|
|||
// Ensure that opening the virtual keyboard is allowed for this specific
|
||||
// InputContext depending on the content.ime.strict.policy pref
|
||||
if (mInputContext.mIMEEnabled != InputContext::IME_DISABLED &&
|
||||
mInputContext.mIMEEnabled != InputContext::IME_PLUGIN) {
|
||||
|
||||
bool useStrictPolicy =
|
||||
Preferences::GetBool("content.ime.strict_policy", false);
|
||||
if (useStrictPolicy && !mInputContext.FocusMovedByUser() &&
|
||||
mInputContext.FocusMovedInContentProcess()) {
|
||||
return NS_OK;
|
||||
}
|
||||
mInputContext.mIMEEnabled != InputContext::IME_PLUGIN &&
|
||||
Preferences::GetBool("content.ime.strict_policy", false) &&
|
||||
!aAction->ContentGotFocusByTrustedCause()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// It is not desired that the hildon's autocomplete mechanism displays
|
||||
|
@ -656,16 +654,12 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext)
|
|||
rectBuf.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGtkIMModule::GetInputMode(InputContext* aContext)
|
||||
InputContext
|
||||
nsGtkIMModule::GetInputContext()
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aContext);
|
||||
*aContext = mInputContext;
|
||||
return NS_OK;
|
||||
return mInputContext;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -61,6 +61,7 @@ class nsGtkIMModule
|
|||
{
|
||||
protected:
|
||||
typedef mozilla::widget::InputContext InputContext;
|
||||
typedef mozilla::widget::InputContextAction InputContextAction;
|
||||
|
||||
public:
|
||||
nsrefcnt AddRef()
|
||||
|
@ -116,9 +117,10 @@ public:
|
|||
|
||||
// IME related nsIWidget methods.
|
||||
nsresult ResetInputState(nsWindow* aCaller);
|
||||
nsresult SetInputMode(nsWindow* aCaller,
|
||||
const InputContext* aContext);
|
||||
nsresult GetInputMode(InputContext* aContext);
|
||||
void SetInputContext(nsWindow* aCaller,
|
||||
const InputContext* aContext,
|
||||
const InputContextAction* aAction);
|
||||
InputContext GetInputContext();
|
||||
nsresult CancelIMEComposition(nsWindow* aCaller);
|
||||
|
||||
// If a software keyboard has been opened, this returns TRUE.
|
||||
|
|
|
@ -6576,20 +6576,26 @@ nsWindow::ResetInputState()
|
|||
return mIMModule ? mIMModule->ResetInputState(this) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::SetInputMode(const InputContext& aContext)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsWindow::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
return mIMModule ? mIMModule->SetInputMode(this, &aContext) : NS_OK;
|
||||
if (!mIMModule) {
|
||||
return;
|
||||
}
|
||||
mIMModule->SetInputContext(this, &aContext, &aAction);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::GetInputMode(InputContext& aContext)
|
||||
NS_IMETHODIMP_(InputContext)
|
||||
nsWindow::GetInputContext()
|
||||
{
|
||||
InputContext context;
|
||||
if (!mIMModule) {
|
||||
aContext.mIMEEnabled = InputContext::IME_DISABLED;
|
||||
return NS_OK;
|
||||
context.mIMEEnabled = InputContext::IME_DISABLED;
|
||||
} else {
|
||||
context = mIMModule->GetInputContext();
|
||||
}
|
||||
return mIMModule->GetInputMode(&aContext);
|
||||
return context;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -320,8 +320,9 @@ public:
|
|||
bool *aIsCancelled);
|
||||
|
||||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext);
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext);
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
NS_IMETHOD CancelIMEComposition();
|
||||
NS_IMETHOD OnIMEFocusChange(bool aFocus);
|
||||
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState);
|
||||
|
|
|
@ -213,6 +213,16 @@ public:
|
|||
nsEventStatus& aStatus);
|
||||
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
||||
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
mInputContext = aInputContext;
|
||||
}
|
||||
NS_IMETHOD_(InputContext) GetInputContext()
|
||||
{
|
||||
return mInputContext;
|
||||
}
|
||||
|
||||
// nsWindow
|
||||
static void ReleaseGlobals();
|
||||
protected:
|
||||
|
@ -294,6 +304,7 @@ protected:
|
|||
#ifdef DEBUG_FOCUS
|
||||
int mWindowIdentifier; // a serial number for each new window
|
||||
#endif
|
||||
InputContext mInputContext;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -3215,10 +3215,11 @@ x11EventFilter(void* message, long* result)
|
|||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::SetInputMode(const InputContext& aContext)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsWindow::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
NS_ENSURE_TRUE(mWidget, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mWidget, );
|
||||
|
||||
// SetSoftwareKeyboardState uses mInputContext,
|
||||
// so, before calling that, record aContext in mInputContext.
|
||||
|
@ -3250,25 +3251,23 @@ nsWindow::SetInputMode(const InputContext& aContext)
|
|||
case InputContext::IME_ENABLED:
|
||||
case InputContext::IME_PASSWORD:
|
||||
case InputContext::IME_PLUGIN:
|
||||
SetSoftwareKeyboardState(true);
|
||||
SetSoftwareKeyboardState(true, aAction);
|
||||
break;
|
||||
default:
|
||||
SetSoftwareKeyboardState(false);
|
||||
SetSoftwareKeyboardState(false, aAction);
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::GetInputMode(InputContext& aContext)
|
||||
NS_IMETHODIMP_(InputContext)
|
||||
nsWindow::GetInputContext()
|
||||
{
|
||||
aContext = mInputContext;
|
||||
return NS_OK;
|
||||
return mInputContext;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::SetSoftwareKeyboardState(bool aOpen)
|
||||
nsWindow::SetSoftwareKeyboardState(bool aOpen,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
if (aOpen) {
|
||||
NS_ENSURE_TRUE(mInputContext.mIMEEnabled !=
|
||||
|
@ -3276,12 +3275,10 @@ nsWindow::SetSoftwareKeyboardState(bool aOpen)
|
|||
|
||||
// Ensure that opening the virtual keyboard is allowed for this specific
|
||||
// InputContext depending on the content.ime.strict.policy pref
|
||||
if (mInputContext.mIMEEnabled != InputContext::IME_PLUGIN) {
|
||||
if (Preferences::GetBool("content.ime.strict_policy", false) &&
|
||||
!mInputContext.FocusMovedByUser() &&
|
||||
mInputContext.FocusMovedInContentProcess()) {
|
||||
return;
|
||||
}
|
||||
if (mInputContext.mIMEEnabled != InputContext::IME_PLUGIN &&
|
||||
Preferences::GetBool("content.ime.strict_policy", false) &&
|
||||
!aAction.ContentGotFocusByTrustedCause()) {
|
||||
return;
|
||||
}
|
||||
#if defined(MOZ_X11) && (MOZ_PLATFORM_MAEMO == 6)
|
||||
// doen't open VKB if plugin did set closed state
|
||||
|
|
|
@ -194,8 +194,9 @@ public:
|
|||
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
|
||||
NS_IMETHOD BeginResizeDrag (nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical);
|
||||
|
||||
NS_IMETHODIMP SetInputMode(const InputContext& aContext);
|
||||
NS_IMETHODIMP GetInputMode(InputContext& aContext);
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
|
||||
//
|
||||
// utility methods
|
||||
|
@ -345,7 +346,7 @@ private:
|
|||
MozQWidget* createQWidget(MozQWidget* parent,
|
||||
nsNativeWidget nativeParent,
|
||||
nsWidgetInitData* aInitData);
|
||||
void SetSoftwareKeyboardState(bool aOpen);
|
||||
void SetSoftwareKeyboardState(bool aOpen, const InputContextAction& aAction);
|
||||
|
||||
MozQWidget* mWidget;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ nsTextStore::Create(nsWindow* aWindow,
|
|||
static_cast<ITextStoreACP*>(this),
|
||||
getter_AddRefs(mContext), &mEditCookie);
|
||||
if (SUCCEEDED(hr)) {
|
||||
SetInputModeInternal(aIMEState);
|
||||
SetInputContextInternal(aIMEState);
|
||||
hr = mDocumentMgr->Push(mContext);
|
||||
}
|
||||
if (SUCCEEDED(hr)) {
|
||||
|
@ -1631,10 +1631,10 @@ nsTextStore::GetIMEOpenState(void)
|
|||
}
|
||||
|
||||
void
|
||||
nsTextStore::SetInputModeInternal(PRUint32 aState)
|
||||
nsTextStore::SetInputContextInternal(PRUint32 aState)
|
||||
{
|
||||
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
|
||||
("TSF: SetInputMode, state=%lu\n", aState));
|
||||
("TSF: SetInputContext, state=%lu\n", aState));
|
||||
|
||||
VARIANT variant;
|
||||
variant.vt = VT_I4;
|
||||
|
|
|
@ -125,10 +125,10 @@ public:
|
|||
sTsfTextStore->CommitCompositionInternal(aDiscard);
|
||||
}
|
||||
|
||||
static void SetInputMode(const InputContext& aContext)
|
||||
static void SetInputContext(const InputContext& aContext)
|
||||
{
|
||||
if (!sTsfTextStore) return;
|
||||
sTsfTextStore->SetInputModeInternal(aContext.mIMEEnabled);
|
||||
sTsfTextStore->SetInputContextInternal(aContext.mIMEEnabled);
|
||||
}
|
||||
|
||||
static nsresult OnFocusChange(bool, nsWindow*, PRUint32);
|
||||
|
@ -194,7 +194,7 @@ protected:
|
|||
bool aDispatchTextEvent = false);
|
||||
HRESULT OnStartCompositionInternal(ITfCompositionView*, ITfRange*, bool);
|
||||
void CommitCompositionInternal(bool);
|
||||
void SetInputModeInternal(PRUint32 aState);
|
||||
void SetInputContextInternal(PRUint32 aState);
|
||||
nsresult OnTextChangeInternal(PRUint32, PRUint32, PRUint32);
|
||||
void OnTextChangeMsgInternal(void);
|
||||
nsresult OnSelectionChangeInternal(void);
|
||||
|
|
|
@ -8065,11 +8065,13 @@ NS_IMETHODIMP nsWindow::GetIMEOpenState(bool* aState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::SetInputMode(const InputContext& aContext)
|
||||
NS_IMETHODIMP_(void)
|
||||
nsWindow::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
PRUint32 status = aContext.mIMEEnabled;
|
||||
#ifdef NS_ENABLE_TSF
|
||||
nsTextStore::SetInputMode(aContext);
|
||||
nsTextStore::SetInputContext(aContext);
|
||||
#endif //NS_ENABLE_TSF
|
||||
#ifdef DEBUG_KBSTATE
|
||||
PR_LOG(gWindowsLog, PR_LOG_ALWAYS,
|
||||
|
@ -8085,18 +8087,17 @@ NS_IMETHODIMP nsWindow::SetInputMode(const InputContext& aContext)
|
|||
status == InputContext::IME_PLUGIN);
|
||||
|
||||
AssociateDefaultIMC(enable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::GetInputMode(InputContext& aContext)
|
||||
NS_IMETHODIMP_(InputContext)
|
||||
nsWindow::GetInputContext()
|
||||
{
|
||||
#ifdef DEBUG_KBSTATE
|
||||
PR_LOG(gWindowsLog, PR_LOG_ALWAYS,
|
||||
("GetInputMode: %s\n", mInputContext.mIMEEnabled ?
|
||||
"Enabled" : "Disabled");
|
||||
#endif
|
||||
aContext = mInputContext;
|
||||
return NS_OK;
|
||||
return mInputContext;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::CancelIMEComposition()
|
||||
|
|
|
@ -181,8 +181,9 @@ public:
|
|||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD SetIMEOpenState(bool aState);
|
||||
NS_IMETHOD GetIMEOpenState(bool* aState);
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext);
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext);
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
NS_IMETHOD CancelIMEComposition();
|
||||
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState);
|
||||
NS_IMETHOD RegisterTouchWindow();
|
||||
|
|
|
@ -408,15 +408,18 @@ PuppetWidget::SetIMEOpenState(bool aState)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::SetInputMode(const InputContext& aContext)
|
||||
NS_IMETHODIMP_(void)
|
||||
PuppetWidget::SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction)
|
||||
{
|
||||
if (mTabChild &&
|
||||
mTabChild->SendSetInputMode(aContext.mIMEEnabled,
|
||||
aContext.mHTMLInputType,
|
||||
aContext.mActionHint, aContext.mReason))
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!mTabChild) {
|
||||
return;
|
||||
}
|
||||
mTabChild->SendSetInputContext(aContext.mIMEEnabled,
|
||||
aContext.mHTMLInputType,
|
||||
aContext.mActionHint,
|
||||
static_cast<PRInt32>(aAction.mCause),
|
||||
static_cast<PRInt32>(aAction.mFocusChange));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -428,13 +431,14 @@ PuppetWidget::GetIMEOpenState(bool *aState)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::GetInputMode(InputContext& aContext)
|
||||
NS_IMETHODIMP_(InputContext)
|
||||
PuppetWidget::GetInputContext()
|
||||
{
|
||||
if (mTabChild &&
|
||||
mTabChild->SendGetIMEEnabled(&aContext.mIMEEnabled))
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
InputContext context;
|
||||
if (mTabChild) {
|
||||
mTabChild->SendGetInputContext(&context.mIMEEnabled);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -170,8 +170,9 @@ public:
|
|||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD SetIMEOpenState(bool aState);
|
||||
NS_IMETHOD GetIMEOpenState(bool *aState);
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext);
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext);
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
NS_IMETHOD CancelComposition();
|
||||
NS_IMETHOD OnIMEFocusChange(bool aFocus);
|
||||
NS_IMETHOD OnIMETextChange(PRUint32 aOffset, PRUint32 aEnd,
|
||||
|
|
|
@ -144,8 +144,6 @@ public:
|
|||
NS_IMETHOD ResetInputState() { return NS_OK; }
|
||||
NS_IMETHOD SetIMEOpenState(bool aState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetIMEOpenState(bool* aState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD SetInputMode(const InputContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetInputMode(InputContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD CancelIMEComposition() { return NS_OK; }
|
||||
NS_IMETHOD SetAcceleratedRendering(bool aEnabled);
|
||||
virtual bool GetAcceleratedRendering();
|
||||
|
|
Загрузка…
Ссылка в новой задаче