tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsDocShellEditorData.h (2169B)


      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/RefPtr.h"
     14 #include "mozilla/dom/Document.h"
     15 #include "mozilla/WeakPtr.h"
     16 #include "nsDocShell.h"
     17 
     18 class nsEditingSession;
     19 
     20 namespace mozilla {
     21 class HTMLEditor;
     22 }
     23 
     24 class nsDocShellEditorData {
     25 public:
     26  explicit nsDocShellEditorData(nsDocShell* aOwningDocShell);
     27  ~nsDocShellEditorData();
     28 
     29  MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult MakeEditable(bool aWaitForUriLoad);
     30  bool GetEditable();
     31  nsEditingSession* GetEditingSession();
     32  mozilla::HTMLEditor* GetHTMLEditor() const { return mHTMLEditor; }
     33  MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
     34  SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor);
     35  MOZ_CAN_RUN_SCRIPT_BOUNDARY void TearDownEditor();
     36  nsresult DetachFromWindow();
     37  nsresult ReattachToWindow(nsDocShell* aDocShell);
     38  bool WaitingForLoad() const { return mMakeEditable; }
     39 
     40 protected:
     41  void EnsureEditingSession();
     42 
     43  // The doc shell that owns us. Weak ref, since it always outlives us.
     44  mozilla::WeakPtr<nsDocShell> mDocShell;
     45 
     46  // Only present for the content root docShell. Session is owned here.
     47  RefPtr<nsEditingSession> mEditingSession;
     48 
     49  // If this frame is editable, store HTML editor here. It's owned here.
     50  RefPtr<mozilla::HTMLEditor> mHTMLEditor;
     51 
     52  // Backup for the corresponding HTMLDocument's  editing state while
     53  // the editor is detached.
     54  mozilla::dom::Document::EditingState mDetachedEditingState;
     55 
     56  // Indicates whether to make an editor after a url load.
     57  bool mMakeEditable;
     58 
     59  // Denotes if the editor is detached from its window. The editor is detached
     60  // while it's stored in the session history bfcache.
     61  bool mIsDetached;
     62 
     63  // Backup for mMakeEditable while the editor is detached.
     64  bool mDetachedMakeEditable;
     65 };
     66 
     67 #endif  // nsDocShellEditorData_h__