|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
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 "nsIHTMLDocument.h" |
|
14 |
|
15 class nsIDocShell; |
|
16 class nsIEditingSession; |
|
17 class nsIEditor; |
|
18 |
|
19 class nsDocShellEditorData |
|
20 { |
|
21 public: |
|
22 |
|
23 nsDocShellEditorData(nsIDocShell* inOwningDocShell); |
|
24 ~nsDocShellEditorData(); |
|
25 |
|
26 nsresult MakeEditable(bool inWaitForUriLoad); |
|
27 bool GetEditable(); |
|
28 nsresult CreateEditor(); |
|
29 nsresult GetEditingSession(nsIEditingSession **outEditingSession); |
|
30 nsresult GetEditor(nsIEditor **outEditor); |
|
31 nsresult SetEditor(nsIEditor *inEditor); |
|
32 void TearDownEditor(); |
|
33 nsresult DetachFromWindow(); |
|
34 nsresult ReattachToWindow(nsIDocShell *aDocShell); |
|
35 bool WaitingForLoad() const { return mMakeEditable; } |
|
36 |
|
37 protected: |
|
38 |
|
39 nsresult EnsureEditingSession(); |
|
40 |
|
41 // The doc shell that owns us. Weak ref, since it always outlives us. |
|
42 nsIDocShell* mDocShell; |
|
43 |
|
44 // Only present for the content root docShell. Session is owned here. |
|
45 nsCOMPtr<nsIEditingSession> mEditingSession; |
|
46 |
|
47 // Indicates whether to make an editor after a url load. |
|
48 bool mMakeEditable; |
|
49 |
|
50 // If this frame is editable, store editor here. Editor is owned here. |
|
51 nsCOMPtr<nsIEditor> mEditor; |
|
52 |
|
53 // Denotes if the editor is detached from its window. The editor is detached |
|
54 // while it's stored in the session history bfcache. |
|
55 bool mIsDetached; |
|
56 |
|
57 // Backup for mMakeEditable while the editor is detached. |
|
58 bool mDetachedMakeEditable; |
|
59 |
|
60 // Backup for the corresponding nsIHTMLDocument's editing state while |
|
61 // the editor is detached. |
|
62 nsIHTMLDocument::EditingState mDetachedEditingState; |
|
63 |
|
64 }; |
|
65 |
|
66 |
|
67 #endif // nsDocShellEditorData_h__ |