dom/events/IMEContentObserver.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 sw=2 et tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_IMEContentObserver_h_
michael@0 8 #define mozilla_IMEContentObserver_h_
michael@0 9
michael@0 10 #include "mozilla/Attributes.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsCycleCollectionParticipant.h"
michael@0 13 #include "nsIDocShell.h" // XXX Why does only this need to be included here?
michael@0 14 #include "nsIReflowObserver.h"
michael@0 15 #include "nsISelectionListener.h"
michael@0 16 #include "nsIScrollObserver.h"
michael@0 17 #include "nsIWidget.h" // for nsIMEUpdatePreference
michael@0 18 #include "nsStubMutationObserver.h"
michael@0 19 #include "nsWeakReference.h"
michael@0 20
michael@0 21 class nsIContent;
michael@0 22 class nsINode;
michael@0 23 class nsISelection;
michael@0 24 class nsPresContext;
michael@0 25
michael@0 26 namespace mozilla {
michael@0 27
michael@0 28 class EventStateManager;
michael@0 29
michael@0 30 // IMEContentObserver notifies widget of any text and selection changes
michael@0 31 // in the currently focused editor
michael@0 32 class IMEContentObserver MOZ_FINAL : public nsISelectionListener,
michael@0 33 public nsStubMutationObserver,
michael@0 34 public nsIReflowObserver,
michael@0 35 public nsIScrollObserver,
michael@0 36 public nsSupportsWeakReference
michael@0 37 {
michael@0 38 public:
michael@0 39 IMEContentObserver();
michael@0 40
michael@0 41 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 42 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(IMEContentObserver,
michael@0 43 nsISelectionListener)
michael@0 44 NS_DECL_NSISELECTIONLISTENER
michael@0 45 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
michael@0 46 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
michael@0 47 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
michael@0 48 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
michael@0 49 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
michael@0 50 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
michael@0 51 NS_DECL_NSIREFLOWOBSERVER
michael@0 52
michael@0 53 // nsIScrollObserver
michael@0 54 virtual void ScrollPositionChanged() MOZ_OVERRIDE;
michael@0 55
michael@0 56 void Init(nsIWidget* aWidget, nsPresContext* aPresContext,
michael@0 57 nsIContent* aContent);
michael@0 58 void Destroy();
michael@0 59 /**
michael@0 60 * IMEContentObserver is stored by EventStateManager during observing.
michael@0 61 * DisconnectFromEventStateManager() is called when EventStateManager stops
michael@0 62 * storing the instance.
michael@0 63 */
michael@0 64 void DisconnectFromEventStateManager();
michael@0 65 bool IsManaging(nsPresContext* aPresContext, nsIContent* aContent);
michael@0 66 bool IsEditorHandlingEventForComposition() const;
michael@0 67 bool KeepAliveDuringDeactive() const
michael@0 68 {
michael@0 69 return mUpdatePreference.WantDuringDeactive();
michael@0 70 }
michael@0 71 nsIWidget* GetWidget() const { return mWidget; }
michael@0 72 nsresult GetSelectionAndRoot(nsISelection** aSelection,
michael@0 73 nsIContent** aRoot) const;
michael@0 74
michael@0 75 private:
michael@0 76 void NotifyContentAdded(nsINode* aContainer, int32_t aStart, int32_t aEnd);
michael@0 77 void ObserveEditableNode();
michael@0 78
michael@0 79 nsCOMPtr<nsIWidget> mWidget;
michael@0 80 nsCOMPtr<nsISelection> mSelection;
michael@0 81 nsCOMPtr<nsIContent> mRootContent;
michael@0 82 nsCOMPtr<nsINode> mEditableNode;
michael@0 83 nsCOMPtr<nsIDocShell> mDocShell;
michael@0 84
michael@0 85 EventStateManager* mESM;
michael@0 86
michael@0 87 nsIMEUpdatePreference mUpdatePreference;
michael@0 88 uint32_t mPreAttrChangeLength;
michael@0 89 };
michael@0 90
michael@0 91 } // namespace mozilla
michael@0 92
michael@0 93 #endif // mozilla_IMEContentObserver_h_

mercurial