editor/composer/src/nsEditingSession.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/composer/src/nsEditingSession.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,149 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsEditingSession_h__
    1.10 +#define nsEditingSession_h__
    1.11 +
    1.12 +
    1.13 +#ifndef nsWeakReference_h__
    1.14 +#include "nsWeakReference.h"            // for nsSupportsWeakReference, etc
    1.15 +#endif
    1.16 +
    1.17 +#include "nsAutoPtr.h"                  // for nsRefPtr
    1.18 +#include "nsCOMPtr.h"                   // for nsCOMPtr
    1.19 +#include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS
    1.20 +#include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
    1.21 +#include "nsWeakReference.h"            // for nsSupportsWeakReference, etc
    1.22 +#include "nscore.h"                     // for nsresult
    1.23 +
    1.24 +#ifndef __gen_nsIWebProgressListener_h__
    1.25 +#include "nsIWebProgressListener.h"
    1.26 +#endif
    1.27 +
    1.28 +#ifndef __gen_nsIEditingSession_h__
    1.29 +#include "nsIEditingSession.h"          // for NS_DECL_NSIEDITINGSESSION, etc
    1.30 +#endif
    1.31 +
    1.32 +#include "nsString.h"                   // for nsCString
    1.33 +
    1.34 +class nsIDOMWindow;
    1.35 +class nsISupports;
    1.36 +class nsITimer;
    1.37 +
    1.38 +#define NS_EDITINGSESSION_CID                            \
    1.39 +{ 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } }
    1.40 +
    1.41 +
    1.42 +class nsComposerCommandsUpdater;
    1.43 +class nsIChannel;
    1.44 +class nsIControllers;
    1.45 +class nsIDocShell;
    1.46 +class nsIEditor;
    1.47 +class nsIWebProgress;
    1.48 +
    1.49 +class nsEditingSession : public nsIEditingSession,
    1.50 +                         public nsIWebProgressListener,
    1.51 +                         public nsSupportsWeakReference
    1.52 +{
    1.53 +public:
    1.54 +
    1.55 +                  nsEditingSession();
    1.56 +  virtual         ~nsEditingSession();
    1.57 +
    1.58 +  // nsISupports
    1.59 +  NS_DECL_ISUPPORTS
    1.60 +
    1.61 +  // nsIWebProgressListener
    1.62 +  NS_DECL_NSIWEBPROGRESSLISTENER
    1.63 +  
    1.64 +  // nsIEditingSession
    1.65 +  NS_DECL_NSIEDITINGSESSION
    1.66 +
    1.67 +protected:
    1.68 +
    1.69 +  nsIDocShell *   GetDocShellFromWindow(nsIDOMWindow *aWindow);
    1.70 +  
    1.71 +  nsresult        SetupEditorCommandController(const char *aControllerClassName,
    1.72 +                                               nsIDOMWindow *aWindow,
    1.73 +                                               nsISupports *aContext,
    1.74 +                                               uint32_t *aControllerId);
    1.75 +
    1.76 +  nsresult        SetContextOnControllerById(nsIControllers* aControllers, 
    1.77 +                                            nsISupports* aContext,
    1.78 +                                            uint32_t aID);
    1.79 +
    1.80 +  nsresult        PrepareForEditing(nsIDOMWindow *aWindow);
    1.81 +
    1.82 +  static void     TimerCallback(nsITimer *aTimer, void *aClosure);
    1.83 +  nsCOMPtr<nsITimer>  mLoadBlankDocTimer;
    1.84 +  
    1.85 +  // progress load stuff
    1.86 +  nsresult        StartDocumentLoad(nsIWebProgress *aWebProgress,
    1.87 +                                    bool isToBeMadeEditable);
    1.88 +  nsresult        EndDocumentLoad(nsIWebProgress *aWebProgress, 
    1.89 +                                  nsIChannel* aChannel, nsresult aStatus,
    1.90 +                                  bool isToBeMadeEditable);
    1.91 +  nsresult        StartPageLoad(nsIChannel *aChannel);
    1.92 +  nsresult        EndPageLoad(nsIWebProgress *aWebProgress, 
    1.93 +                              nsIChannel* aChannel, nsresult aStatus);
    1.94 +  
    1.95 +  bool            IsProgressForTargetDocument(nsIWebProgress *aWebProgress);
    1.96 +
    1.97 +  void            RemoveEditorControllers(nsIDOMWindow *aWindow);
    1.98 +  void            RemoveWebProgressListener(nsIDOMWindow *aWindow);
    1.99 +  void            RestoreAnimationMode(nsIDOMWindow *aWindow);
   1.100 +  void            RemoveListenersAndControllers(nsIDOMWindow *aWindow,
   1.101 +                                                nsIEditor *aEditor);
   1.102 +
   1.103 +protected:
   1.104 +
   1.105 +  bool            mDoneSetup;    // have we prepared for editing yet?
   1.106 +
   1.107 +  // Used to prevent double creation of editor because nsIWebProgressListener
   1.108 +  //  receives a STATE_STOP notification before the STATE_START 
   1.109 +  //  for our document, so we wait for the STATE_START, then STATE_STOP 
   1.110 +  //  before creating an editor
   1.111 +  bool            mCanCreateEditor; 
   1.112 +
   1.113 +  bool            mInteractive;
   1.114 +  bool            mMakeWholeDocumentEditable;
   1.115 +
   1.116 +  bool            mDisabledJSAndPlugins;
   1.117 +
   1.118 +  // True if scripts were enabled before the editor turned scripts
   1.119 +  // off, otherwise false.
   1.120 +  bool            mScriptsEnabled;
   1.121 +
   1.122 +  // True if plugins were enabled before the editor turned plugins
   1.123 +  // off, otherwise false.
   1.124 +  bool            mPluginsEnabled;
   1.125 +
   1.126 +  bool            mProgressListenerRegistered;
   1.127 +
   1.128 +  // The image animation mode before it was turned off.
   1.129 +  uint16_t        mImageAnimationMode;
   1.130 +
   1.131 +  // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
   1.132 +  // MORE THAN ONE EDITOR PER EDITING SESSION
   1.133 +  nsRefPtr<nsComposerCommandsUpdater> mStateMaintainer;
   1.134 +  
   1.135 +  // Save the editor type so we can create the editor after loading uri
   1.136 +  nsCString       mEditorType; 
   1.137 +  uint32_t        mEditorFlags;
   1.138 +  uint32_t        mEditorStatus;
   1.139 +  uint32_t        mBaseCommandControllerId;
   1.140 +  uint32_t        mDocStateControllerId;
   1.141 +  uint32_t        mHTMLCommandControllerId;
   1.142 +
   1.143 +  // Make sure the docshell we use is safe
   1.144 +  nsWeakPtr       mDocShell;
   1.145 +
   1.146 +  // See if we can reuse an existing editor
   1.147 +  nsWeakPtr       mExistingEditor;
   1.148 +};
   1.149 +
   1.150 +
   1.151 +
   1.152 +#endif // nsEditingSession_h__

mercurial