2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsIMEStateManager_h__
|
|
|
|
#define nsIMEStateManager_h__
|
|
|
|
|
2013-09-24 03:04:14 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2011-11-27 03:51:52 -08:00
|
|
|
#include "nsIWidget.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-25 22:47:45 -07:00
|
|
|
class nsDispatchingCallback;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIContent;
|
2011-11-27 03:51:53 -08:00
|
|
|
class nsIDOMMouseEvent;
|
2012-09-25 22:47:45 -07:00
|
|
|
class nsINode;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsPIDOMWindow;
|
|
|
|
class nsPresContext;
|
2009-02-10 12:56:51 -08:00
|
|
|
class nsTextStateManager;
|
|
|
|
class nsISelection;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-25 22:47:45 -07:00
|
|
|
namespace mozilla {
|
|
|
|
class TextCompositionArray;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* IME state manager
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsIMEStateManager
|
|
|
|
{
|
2012-10-25 17:49:13 -07:00
|
|
|
friend class nsTextStateManager;
|
2011-11-27 03:51:52 -08:00
|
|
|
protected:
|
2011-11-27 03:51:53 -08:00
|
|
|
typedef mozilla::widget::IMEState IMEState;
|
2011-11-27 03:51:52 -08:00
|
|
|
typedef mozilla::widget::InputContext InputContext;
|
|
|
|
typedef mozilla::widget::InputContextAction InputContextAction;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-09-25 22:47:45 -07:00
|
|
|
static void Shutdown();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsresult OnDestroyPresContext(nsPresContext* aPresContext);
|
|
|
|
static nsresult OnRemoveContent(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent);
|
2011-11-27 03:51:52 -08:00
|
|
|
/**
|
|
|
|
* OnChangeFocus() should be called when focused content is changed or
|
2012-10-25 17:49:13 -07:00
|
|
|
* IME enabled state is changed. If nobody has focus, set both aPresContext
|
|
|
|
* and aContent nullptr. E.g., all windows are deactivated.
|
2011-11-27 03:51:52 -08:00
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsresult OnChangeFocus(nsPresContext* aPresContext,
|
2011-04-20 05:47:40 -07:00
|
|
|
nsIContent* aContent,
|
2011-11-27 03:51:52 -08:00
|
|
|
InputContextAction::Cause aCause);
|
2011-09-28 23:19:26 -07:00
|
|
|
static void OnInstalledMenuKeyboardListener(bool aInstalling);
|
2009-02-10 12:56:51 -08:00
|
|
|
|
|
|
|
// These two methods manage focus and selection/text observers.
|
|
|
|
// They are separate from OnChangeFocus above because this offers finer
|
|
|
|
// control compared to having the two methods incorporated into OnChangeFocus
|
|
|
|
|
|
|
|
// Get the focused editor's selection and root
|
|
|
|
static nsresult GetFocusSelectionAndRoot(nsISelection** aSel,
|
|
|
|
nsIContent** aRoot);
|
2010-05-26 19:04:14 -07:00
|
|
|
// This method updates the current IME state. However, if the enabled state
|
|
|
|
// isn't changed by the new state, this method does nothing.
|
|
|
|
// Note that this method changes the IME state of the active element in the
|
|
|
|
// widget. So, the caller must have focus.
|
2011-11-27 03:51:53 -08:00
|
|
|
static void UpdateIMEState(const IMEState &aNewIMEState,
|
|
|
|
nsIContent* aContent);
|
2010-05-26 19:04:14 -07:00
|
|
|
|
2011-11-27 03:51:53 -08:00
|
|
|
// This method is called when user clicked in an editor.
|
|
|
|
// aContent must be:
|
|
|
|
// If the editor is for <input> or <textarea>, the element.
|
|
|
|
// If the editor is for contenteditable, the active editinghost.
|
2013-04-02 18:14:24 -07:00
|
|
|
// If the editor is for designMode, nullptr.
|
2011-11-27 03:51:53 -08:00
|
|
|
static void OnClickInEditor(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIDOMMouseEvent* aMouseEvent);
|
|
|
|
|
2012-10-25 17:49:13 -07:00
|
|
|
// This method is called when editor actually gets focus.
|
|
|
|
// aContent must be:
|
|
|
|
// If the editor is for <input> or <textarea>, the element.
|
|
|
|
// If the editor is for contenteditable, the active editinghost.
|
2013-04-02 18:14:24 -07:00
|
|
|
// If the editor is for designMode, nullptr.
|
2012-10-25 17:49:13 -07:00
|
|
|
static void OnFocusInEditor(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent);
|
|
|
|
|
2012-09-25 22:47:45 -07:00
|
|
|
/**
|
|
|
|
* All DOM composition events and DOM text events must be dispatched via
|
|
|
|
* DispatchCompositionEvent() for storing the composition target
|
|
|
|
* and ensuring a set of composition events must be fired the stored target.
|
|
|
|
* If the stored composition event target is destroying, this removes the
|
|
|
|
* stored composition automatically.
|
|
|
|
*/
|
|
|
|
static void DispatchCompositionEvent(nsINode* aEventTargetNode,
|
|
|
|
nsPresContext* aPresContext,
|
2013-10-01 20:46:04 -07:00
|
|
|
mozilla::WidgetEvent* aEvent,
|
2012-09-25 22:47:45 -07:00
|
|
|
nsEventStatus* aStatus,
|
|
|
|
nsDispatchingCallback* aCallBack);
|
|
|
|
|
2012-09-25 22:47:51 -07:00
|
|
|
/**
|
|
|
|
* Send a notification to IME. It depends on the IME or platform spec what
|
|
|
|
* will occur (or not occur).
|
|
|
|
*/
|
|
|
|
static nsresult NotifyIME(mozilla::widget::NotificationToIME aNotification,
|
|
|
|
nsIWidget* aWidget);
|
|
|
|
static nsresult NotifyIME(mozilla::widget::NotificationToIME aNotification,
|
|
|
|
nsPresContext* aPresContext);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2011-11-27 03:51:52 -08:00
|
|
|
static nsresult OnChangeFocusInternal(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
InputContextAction aAction);
|
2011-11-27 03:51:53 -08:00
|
|
|
static void SetIMEState(const IMEState &aState,
|
|
|
|
nsIContent* aContent,
|
2011-11-27 03:51:52 -08:00
|
|
|
nsIWidget* aWidget,
|
|
|
|
InputContextAction aAction);
|
2011-11-27 03:51:53 -08:00
|
|
|
static IMEState GetNewIMEState(nsPresContext* aPresContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIContent* aContent);
|
|
|
|
|
2012-09-25 22:47:45 -07:00
|
|
|
static void EnsureTextCompositionArray();
|
2012-10-25 17:49:13 -07:00
|
|
|
static void CreateTextStateManager();
|
|
|
|
static void DestroyTextStateManager();
|
|
|
|
|
|
|
|
static bool IsEditable(nsINode* node);
|
|
|
|
static nsINode* GetRootEditableNode(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-30 16:22:22 -07:00
|
|
|
static bool IsEditableIMEState(nsIWidget* aWidget);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsIContent* sContent;
|
|
|
|
static nsPresContext* sPresContext;
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool sInstalledMenuKeyboardListener;
|
2012-11-09 00:40:40 -08:00
|
|
|
static bool sIsTestingIME;
|
2009-02-10 12:56:51 -08:00
|
|
|
|
|
|
|
static nsTextStateManager* sTextStateObserver;
|
2012-09-25 22:47:45 -07:00
|
|
|
|
|
|
|
// All active compositions in the process are stored by this array.
|
|
|
|
// When you get an item of this array and use it, please be careful.
|
|
|
|
// The instances in this array can be destroyed automatically if you do
|
|
|
|
// something to cause committing or canceling the composition.
|
|
|
|
static mozilla::TextCompositionArray* sTextCompositions;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsIMEStateManager_h__
|