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.

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

mercurial