2014-03-07 17:20:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_IMEContentObserver_h_
|
|
|
|
#define mozilla_IMEContentObserver_h_
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2014-04-23 17:36:14 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-03-07 17:20:07 -08:00
|
|
|
#include "nsIDocShell.h" // XXX Why does only this need to be included here?
|
|
|
|
#include "nsIReflowObserver.h"
|
|
|
|
#include "nsISelectionListener.h"
|
|
|
|
#include "nsIScrollObserver.h"
|
|
|
|
#include "nsIWidget.h" // for nsIMEUpdatePreference
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
|
|
|
class nsIContent;
|
|
|
|
class nsINode;
|
|
|
|
class nsISelection;
|
|
|
|
class nsPresContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-04-23 17:36:15 -07:00
|
|
|
class EventStateManager;
|
|
|
|
|
2014-03-07 17:20:07 -08:00
|
|
|
// IMEContentObserver notifies widget of any text and selection changes
|
|
|
|
// in the currently focused editor
|
|
|
|
class IMEContentObserver MOZ_FINAL : public nsISelectionListener,
|
|
|
|
public nsStubMutationObserver,
|
|
|
|
public nsIReflowObserver,
|
|
|
|
public nsIScrollObserver,
|
|
|
|
public nsSupportsWeakReference
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IMEContentObserver();
|
|
|
|
|
2014-04-23 17:36:14 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(IMEContentObserver,
|
|
|
|
nsISelectionListener)
|
2014-03-07 17:20:07 -08:00
|
|
|
NS_DECL_NSISELECTIONLISTENER
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIREFLOWOBSERVER
|
|
|
|
|
|
|
|
// nsIScrollObserver
|
|
|
|
virtual void ScrollPositionChanged() MOZ_OVERRIDE;
|
|
|
|
|
2014-03-07 17:20:07 -08:00
|
|
|
void Init(nsIWidget* aWidget, nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent);
|
|
|
|
void Destroy();
|
2014-04-23 17:36:15 -07:00
|
|
|
/**
|
|
|
|
* IMEContentObserver is stored by EventStateManager during observing.
|
|
|
|
* DisconnectFromEventStateManager() is called when EventStateManager stops
|
|
|
|
* storing the instance.
|
|
|
|
*/
|
|
|
|
void DisconnectFromEventStateManager();
|
2014-03-07 17:20:07 -08:00
|
|
|
bool IsManaging(nsPresContext* aPresContext, nsIContent* aContent);
|
|
|
|
bool IsEditorHandlingEventForComposition() const;
|
|
|
|
bool KeepAliveDuringDeactive() const
|
2014-03-07 17:20:07 -08:00
|
|
|
{
|
|
|
|
return mUpdatePreference.WantDuringDeactive();
|
|
|
|
}
|
2014-03-07 17:20:07 -08:00
|
|
|
nsIWidget* GetWidget() const { return mWidget; }
|
|
|
|
nsresult GetSelectionAndRoot(nsISelection** aSelection,
|
|
|
|
nsIContent** aRoot) const;
|
2014-03-07 17:20:07 -08:00
|
|
|
|
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
~IMEContentObserver() {}
|
|
|
|
|
2014-03-07 17:20:07 -08:00
|
|
|
void NotifyContentAdded(nsINode* aContainer, int32_t aStart, int32_t aEnd);
|
|
|
|
void ObserveEditableNode();
|
|
|
|
|
2014-03-07 17:20:07 -08:00
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
|
|
|
nsCOMPtr<nsISelection> mSelection;
|
|
|
|
nsCOMPtr<nsIContent> mRootContent;
|
|
|
|
nsCOMPtr<nsINode> mEditableNode;
|
|
|
|
nsCOMPtr<nsIDocShell> mDocShell;
|
2014-04-23 17:36:15 -07:00
|
|
|
|
|
|
|
EventStateManager* mESM;
|
|
|
|
|
2014-03-07 17:20:07 -08:00
|
|
|
nsIMEUpdatePreference mUpdatePreference;
|
|
|
|
uint32_t mPreAttrChangeLength;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-03-07 17:20:07 -08:00
|
|
|
#endif // mozilla_IMEContentObserver_h_
|