1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 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/. */ 6 #ifndef nsDocShellEditorData_h__ 7 #define nsDocShellEditorData_h__ 8 9 #ifndef nsCOMPtr_h___ 10 #include "nsCOMPtr.h" 11 #endif 12 13 #include "mozilla/HTMLEditor.h" 14 #include "mozilla/RefPtr.h" 15 #include "nsIHTMLDocument.h" 16 17 class nsIDocShell; 18 class nsIEditingSession; 19 20 class nsDocShellEditorData { 21 public: 22 explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell); 23 ~nsDocShellEditorData(); 24 25 nsresult MakeEditable(bool aWaitForUriLoad); 26 bool GetEditable(); 27 nsresult CreateEditor(); 28 nsresult GetEditingSession(nsIEditingSession** aResult); GetHTMLEditor()29 mozilla::HTMLEditor* GetHTMLEditor() const { return mHTMLEditor; } 30 nsresult SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor); 31 void TearDownEditor(); 32 nsresult DetachFromWindow(); 33 nsresult ReattachToWindow(nsIDocShell* aDocShell); WaitingForLoad()34 bool WaitingForLoad() const { return mMakeEditable; } 35 36 protected: 37 nsresult EnsureEditingSession(); 38 39 // The doc shell that owns us. Weak ref, since it always outlives us. 40 nsIDocShell* mDocShell; 41 42 // Only present for the content root docShell. Session is owned here. 43 nsCOMPtr<nsIEditingSession> mEditingSession; 44 45 // If this frame is editable, store HTML editor here. It's owned here. 46 RefPtr<mozilla::HTMLEditor> mHTMLEditor; 47 48 // Backup for the corresponding nsIHTMLDocument's editing state while 49 // the editor is detached. 50 nsIHTMLDocument::EditingState mDetachedEditingState; 51 52 // Indicates whether to make an editor after a url load. 53 bool mMakeEditable; 54 55 // Denotes if the editor is detached from its window. The editor is detached 56 // while it's stored in the session history bfcache. 57 bool mIsDetached; 58 59 // Backup for mMakeEditable while the editor is detached. 60 bool mDetachedMakeEditable; 61 }; 62 63 #endif // nsDocShellEditorData_h__ 64