nsDocShellEditorData.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsDocShellEditorData_h__
  6. #define nsDocShellEditorData_h__
  7. #ifndef nsCOMPtr_h___
  8. #include "nsCOMPtr.h"
  9. #endif
  10. #include "nsIHTMLDocument.h"
  11. class nsIDocShell;
  12. class nsIEditingSession;
  13. class nsIEditor;
  14. class nsDocShellEditorData
  15. {
  16. public:
  17. explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);
  18. ~nsDocShellEditorData();
  19. nsresult MakeEditable(bool aWaitForUriLoad);
  20. bool GetEditable();
  21. nsresult CreateEditor();
  22. nsresult GetEditingSession(nsIEditingSession** aResult);
  23. nsresult GetEditor(nsIEditor** aResult);
  24. nsresult SetEditor(nsIEditor* aEditor);
  25. void TearDownEditor();
  26. nsresult DetachFromWindow();
  27. nsresult ReattachToWindow(nsIDocShell* aDocShell);
  28. bool WaitingForLoad() const { return mMakeEditable; }
  29. protected:
  30. nsresult EnsureEditingSession();
  31. // The doc shell that owns us. Weak ref, since it always outlives us.
  32. nsIDocShell* mDocShell;
  33. // Only present for the content root docShell. Session is owned here.
  34. nsCOMPtr<nsIEditingSession> mEditingSession;
  35. // Indicates whether to make an editor after a url load.
  36. bool mMakeEditable;
  37. // If this frame is editable, store editor here. Editor is owned here.
  38. nsCOMPtr<nsIEditor> mEditor;
  39. // Denotes if the editor is detached from its window. The editor is detached
  40. // while it's stored in the session history bfcache.
  41. bool mIsDetached;
  42. // Backup for mMakeEditable while the editor is detached.
  43. bool mDetachedMakeEditable;
  44. // Backup for the corresponding nsIHTMLDocument's editing state while
  45. // the editor is detached.
  46. nsIHTMLDocument::EditingState mDetachedEditingState;
  47. };
  48. #endif // nsDocShellEditorData_h__