Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsEditingSession_h__ |
michael@0 | 7 | #define nsEditingSession_h__ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef nsWeakReference_h__ |
michael@0 | 11 | #include "nsWeakReference.h" // for nsSupportsWeakReference, etc |
michael@0 | 12 | #endif |
michael@0 | 13 | |
michael@0 | 14 | #include "nsAutoPtr.h" // for nsRefPtr |
michael@0 | 15 | #include "nsCOMPtr.h" // for nsCOMPtr |
michael@0 | 16 | #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS |
michael@0 | 17 | #include "nsIWeakReferenceUtils.h" // for nsWeakPtr |
michael@0 | 18 | #include "nsWeakReference.h" // for nsSupportsWeakReference, etc |
michael@0 | 19 | #include "nscore.h" // for nsresult |
michael@0 | 20 | |
michael@0 | 21 | #ifndef __gen_nsIWebProgressListener_h__ |
michael@0 | 22 | #include "nsIWebProgressListener.h" |
michael@0 | 23 | #endif |
michael@0 | 24 | |
michael@0 | 25 | #ifndef __gen_nsIEditingSession_h__ |
michael@0 | 26 | #include "nsIEditingSession.h" // for NS_DECL_NSIEDITINGSESSION, etc |
michael@0 | 27 | #endif |
michael@0 | 28 | |
michael@0 | 29 | #include "nsString.h" // for nsCString |
michael@0 | 30 | |
michael@0 | 31 | class nsIDOMWindow; |
michael@0 | 32 | class nsISupports; |
michael@0 | 33 | class nsITimer; |
michael@0 | 34 | |
michael@0 | 35 | #define NS_EDITINGSESSION_CID \ |
michael@0 | 36 | { 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } } |
michael@0 | 37 | |
michael@0 | 38 | |
michael@0 | 39 | class nsComposerCommandsUpdater; |
michael@0 | 40 | class nsIChannel; |
michael@0 | 41 | class nsIControllers; |
michael@0 | 42 | class nsIDocShell; |
michael@0 | 43 | class nsIEditor; |
michael@0 | 44 | class nsIWebProgress; |
michael@0 | 45 | |
michael@0 | 46 | class nsEditingSession : public nsIEditingSession, |
michael@0 | 47 | public nsIWebProgressListener, |
michael@0 | 48 | public nsSupportsWeakReference |
michael@0 | 49 | { |
michael@0 | 50 | public: |
michael@0 | 51 | |
michael@0 | 52 | nsEditingSession(); |
michael@0 | 53 | virtual ~nsEditingSession(); |
michael@0 | 54 | |
michael@0 | 55 | // nsISupports |
michael@0 | 56 | NS_DECL_ISUPPORTS |
michael@0 | 57 | |
michael@0 | 58 | // nsIWebProgressListener |
michael@0 | 59 | NS_DECL_NSIWEBPROGRESSLISTENER |
michael@0 | 60 | |
michael@0 | 61 | // nsIEditingSession |
michael@0 | 62 | NS_DECL_NSIEDITINGSESSION |
michael@0 | 63 | |
michael@0 | 64 | protected: |
michael@0 | 65 | |
michael@0 | 66 | nsIDocShell * GetDocShellFromWindow(nsIDOMWindow *aWindow); |
michael@0 | 67 | |
michael@0 | 68 | nsresult SetupEditorCommandController(const char *aControllerClassName, |
michael@0 | 69 | nsIDOMWindow *aWindow, |
michael@0 | 70 | nsISupports *aContext, |
michael@0 | 71 | uint32_t *aControllerId); |
michael@0 | 72 | |
michael@0 | 73 | nsresult SetContextOnControllerById(nsIControllers* aControllers, |
michael@0 | 74 | nsISupports* aContext, |
michael@0 | 75 | uint32_t aID); |
michael@0 | 76 | |
michael@0 | 77 | nsresult PrepareForEditing(nsIDOMWindow *aWindow); |
michael@0 | 78 | |
michael@0 | 79 | static void TimerCallback(nsITimer *aTimer, void *aClosure); |
michael@0 | 80 | nsCOMPtr<nsITimer> mLoadBlankDocTimer; |
michael@0 | 81 | |
michael@0 | 82 | // progress load stuff |
michael@0 | 83 | nsresult StartDocumentLoad(nsIWebProgress *aWebProgress, |
michael@0 | 84 | bool isToBeMadeEditable); |
michael@0 | 85 | nsresult EndDocumentLoad(nsIWebProgress *aWebProgress, |
michael@0 | 86 | nsIChannel* aChannel, nsresult aStatus, |
michael@0 | 87 | bool isToBeMadeEditable); |
michael@0 | 88 | nsresult StartPageLoad(nsIChannel *aChannel); |
michael@0 | 89 | nsresult EndPageLoad(nsIWebProgress *aWebProgress, |
michael@0 | 90 | nsIChannel* aChannel, nsresult aStatus); |
michael@0 | 91 | |
michael@0 | 92 | bool IsProgressForTargetDocument(nsIWebProgress *aWebProgress); |
michael@0 | 93 | |
michael@0 | 94 | void RemoveEditorControllers(nsIDOMWindow *aWindow); |
michael@0 | 95 | void RemoveWebProgressListener(nsIDOMWindow *aWindow); |
michael@0 | 96 | void RestoreAnimationMode(nsIDOMWindow *aWindow); |
michael@0 | 97 | void RemoveListenersAndControllers(nsIDOMWindow *aWindow, |
michael@0 | 98 | nsIEditor *aEditor); |
michael@0 | 99 | |
michael@0 | 100 | protected: |
michael@0 | 101 | |
michael@0 | 102 | bool mDoneSetup; // have we prepared for editing yet? |
michael@0 | 103 | |
michael@0 | 104 | // Used to prevent double creation of editor because nsIWebProgressListener |
michael@0 | 105 | // receives a STATE_STOP notification before the STATE_START |
michael@0 | 106 | // for our document, so we wait for the STATE_START, then STATE_STOP |
michael@0 | 107 | // before creating an editor |
michael@0 | 108 | bool mCanCreateEditor; |
michael@0 | 109 | |
michael@0 | 110 | bool mInteractive; |
michael@0 | 111 | bool mMakeWholeDocumentEditable; |
michael@0 | 112 | |
michael@0 | 113 | bool mDisabledJSAndPlugins; |
michael@0 | 114 | |
michael@0 | 115 | // True if scripts were enabled before the editor turned scripts |
michael@0 | 116 | // off, otherwise false. |
michael@0 | 117 | bool mScriptsEnabled; |
michael@0 | 118 | |
michael@0 | 119 | // True if plugins were enabled before the editor turned plugins |
michael@0 | 120 | // off, otherwise false. |
michael@0 | 121 | bool mPluginsEnabled; |
michael@0 | 122 | |
michael@0 | 123 | bool mProgressListenerRegistered; |
michael@0 | 124 | |
michael@0 | 125 | // The image animation mode before it was turned off. |
michael@0 | 126 | uint16_t mImageAnimationMode; |
michael@0 | 127 | |
michael@0 | 128 | // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT |
michael@0 | 129 | // MORE THAN ONE EDITOR PER EDITING SESSION |
michael@0 | 130 | nsRefPtr<nsComposerCommandsUpdater> mStateMaintainer; |
michael@0 | 131 | |
michael@0 | 132 | // Save the editor type so we can create the editor after loading uri |
michael@0 | 133 | nsCString mEditorType; |
michael@0 | 134 | uint32_t mEditorFlags; |
michael@0 | 135 | uint32_t mEditorStatus; |
michael@0 | 136 | uint32_t mBaseCommandControllerId; |
michael@0 | 137 | uint32_t mDocStateControllerId; |
michael@0 | 138 | uint32_t mHTMLCommandControllerId; |
michael@0 | 139 | |
michael@0 | 140 | // Make sure the docshell we use is safe |
michael@0 | 141 | nsWeakPtr mDocShell; |
michael@0 | 142 | |
michael@0 | 143 | // See if we can reuse an existing editor |
michael@0 | 144 | nsWeakPtr mExistingEditor; |
michael@0 | 145 | }; |
michael@0 | 146 | |
michael@0 | 147 | |
michael@0 | 148 | |
michael@0 | 149 | #endif // nsEditingSession_h__ |