2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-01-26 05:16:14 +03:00
|
|
|
|
|
|
|
#ifndef nsEditingSession_h__
|
|
|
|
#define nsEditingSession_h__
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS
|
|
|
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
|
|
|
#include "nsWeakReference.h" // for nsSupportsWeakReference, etc
|
|
|
|
#include "nscore.h" // for nsresult
|
2002-11-13 02:03:27 +03:00
|
|
|
|
2001-04-06 03:57:22 +04:00
|
|
|
#ifndef __gen_nsIWebProgressListener_h__
|
|
|
|
# include "nsIWebProgressListener.h"
|
2001-01-26 05:16:14 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __gen_nsIEditingSession_h__
|
2012-07-13 10:33:42 +04:00
|
|
|
# include "nsIEditingSession.h" // for NS_DECL_NSIEDITINGSESSION, etc
|
2001-01-26 05:16:14 +03:00
|
|
|
#endif
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsString.h" // for nsCString
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
class mozIDOMWindowProxy;
|
2019-04-03 15:52:14 +03:00
|
|
|
class nsBaseCommandController;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIDOMWindow;
|
|
|
|
class nsISupports;
|
|
|
|
class nsITimer;
|
2002-11-13 02:03:27 +03:00
|
|
|
class nsIChannel;
|
2003-07-14 18:37:23 +04:00
|
|
|
class nsIControllers;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIDocShell;
|
|
|
|
class nsIWebProgress;
|
2001-04-06 03:57:22 +04:00
|
|
|
|
2017-08-04 16:53:28 +03:00
|
|
|
namespace mozilla {
|
2018-01-26 08:06:29 +03:00
|
|
|
class ComposerCommandsUpdater;
|
2017-08-04 16:53:28 +03:00
|
|
|
class HTMLEditor;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsEditingSession final : public nsIEditingSession,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIWebProgressListener,
|
|
|
|
public nsSupportsWeakReference {
|
2001-01-26 05:16:14 +03:00
|
|
|
public:
|
2014-06-24 02:40:02 +04:00
|
|
|
nsEditingSession();
|
2001-01-26 05:16:14 +03:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2001-04-06 03:57:22 +04:00
|
|
|
// nsIWebProgressListener
|
|
|
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-01-26 05:16:14 +03:00
|
|
|
// nsIEditingSession
|
|
|
|
NS_DECL_NSIEDITINGSESSION
|
|
|
|
|
2019-06-06 08:31:16 +03:00
|
|
|
/**
|
|
|
|
* Removes all the editor's controllers/listeners etc and makes the window
|
|
|
|
* uneditable.
|
|
|
|
*/
|
|
|
|
nsresult DetachFromWindow(nsPIDOMWindowOuter* aWindow);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undos DetachFromWindow(), reattaches this editing session/editor
|
|
|
|
* to the window.
|
|
|
|
*/
|
|
|
|
nsresult ReattachToWindow(nsPIDOMWindowOuter* aWindow);
|
|
|
|
|
2001-01-26 05:16:14 +03:00
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsEditingSession();
|
2001-01-26 05:16:14 +03:00
|
|
|
|
2019-04-03 15:52:14 +03:00
|
|
|
typedef already_AddRefed<nsBaseCommandController> (*ControllerCreatorFn)();
|
2018-09-07 16:24:34 +03:00
|
|
|
|
|
|
|
nsresult SetupEditorCommandController(
|
|
|
|
ControllerCreatorFn aControllerCreatorFn, mozIDOMWindowProxy* aWindow,
|
|
|
|
nsISupports* aContext, uint32_t* aControllerId);
|
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
nsresult SetContextOnControllerById(nsIControllers* aControllers,
|
2003-04-10 22:44:03 +04:00
|
|
|
nsISupports* aContext, uint32_t aID);
|
2001-01-26 05:16:14 +03:00
|
|
|
|
2019-06-06 08:31:16 +03:00
|
|
|
/**
|
|
|
|
* Set the editor on the controller(s) for this window
|
|
|
|
*/
|
|
|
|
nsresult SetEditorOnControllers(nsPIDOMWindowOuter& aWindow,
|
|
|
|
mozilla::HTMLEditor* aEditor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup editor and related support objects
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetupEditorOnWindow(nsPIDOMWindowOuter& aWindow);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsresult PrepareForEditing(nsPIDOMWindowOuter* aWindow);
|
2002-11-13 02:03:27 +03:00
|
|
|
|
|
|
|
static void TimerCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
nsCOMPtr<nsITimer> mLoadBlankDocTimer;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-04-06 03:57:22 +04:00
|
|
|
// progress load stuff
|
2003-02-27 17:06:29 +03:00
|
|
|
nsresult StartDocumentLoad(nsIWebProgress* aWebProgress,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isToBeMadeEditable);
|
2019-03-30 14:55:29 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-05-28 18:58:42 +03:00
|
|
|
nsresult EndDocumentLoad(nsIWebProgress* aWebProgress, nsIChannel* aChannel,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult aStatus, bool isToBeMadeEditable);
|
2002-11-13 02:03:27 +03:00
|
|
|
nsresult StartPageLoad(nsIChannel* aChannel);
|
2015-05-28 18:58:42 +03:00
|
|
|
nsresult EndPageLoad(nsIWebProgress* aWebProgress, nsIChannel* aChannel,
|
2002-11-13 02:03:27 +03:00
|
|
|
nsresult aStatus);
|
2001-04-06 03:57:22 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
bool IsProgressForTargetDocument(nsIWebProgress* aWebProgress);
|
2008-04-24 01:36:17 +04:00
|
|
|
|
2001-01-26 05:16:14 +03:00
|
|
|
void RemoveEditorControllers(nsPIDOMWindowOuter* aWindow);
|
|
|
|
void RemoveWebProgressListener(nsPIDOMWindowOuter* aWindow);
|
2016-01-30 20:05:36 +03:00
|
|
|
void RestoreAnimationMode(nsPIDOMWindowOuter* aWindow);
|
|
|
|
void RemoveListenersAndControllers(nsPIDOMWindowOuter* aWindow,
|
2017-08-04 16:53:28 +03:00
|
|
|
mozilla::HTMLEditor* aHTMLEditor);
|
2001-01-26 05:16:14 +03:00
|
|
|
|
2019-02-10 13:41:43 +03:00
|
|
|
/**
|
|
|
|
* Disable scripts and plugins in aDocShell.
|
|
|
|
*/
|
|
|
|
nsresult DisableJSAndPlugins(nsIDocShell& aDocShell);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore JS and plugins (enable/disable them) according to the state they
|
|
|
|
* were before the last call to disableJSAndPlugins.
|
|
|
|
*/
|
|
|
|
nsresult RestoreJSAndPlugins(nsPIDOMWindowOuter* aWindow);
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
protected:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDoneSetup; // have we prepared for editing yet?
|
2001-04-06 03:57:22 +04:00
|
|
|
|
2002-11-13 02:03:27 +03:00
|
|
|
// Used to prevent double creation of editor because nsIWebProgressListener
|
2015-05-28 18:58:42 +03:00
|
|
|
// receives a STATE_STOP notification before the STATE_START
|
|
|
|
// for our document, so we wait for the STATE_START, then STATE_STOP
|
2002-11-13 02:03:27 +03:00
|
|
|
// before creating an editor
|
2015-05-28 18:58:42 +03:00
|
|
|
bool mCanCreateEditor;
|
2005-02-24 00:27:20 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInteractive;
|
|
|
|
bool mMakeWholeDocumentEditable;
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDisabledJSAndPlugins;
|
2007-11-12 17:47:03 +03:00
|
|
|
|
2005-02-24 00:27:20 +03:00
|
|
|
// True if scripts were enabled before the editor turned scripts
|
|
|
|
// off, otherwise false.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mScriptsEnabled;
|
2005-02-24 00:27:20 +03:00
|
|
|
|
2005-03-02 23:17:28 +03:00
|
|
|
// True if plugins were enabled before the editor turned plugins
|
|
|
|
// off, otherwise false.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mPluginsEnabled;
|
2005-03-02 23:17:28 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mProgressListenerRegistered;
|
2005-02-25 21:16:20 +03:00
|
|
|
|
2005-02-24 00:27:20 +03:00
|
|
|
// The image animation mode before it was turned off.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mImageAnimationMode;
|
2002-11-13 02:03:27 +03:00
|
|
|
|
|
|
|
// THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
|
|
|
|
// MORE THAN ONE EDITOR PER EDITING SESSION
|
2018-01-26 08:38:05 +03:00
|
|
|
RefPtr<mozilla::ComposerCommandsUpdater> mComposerCommandsUpdater;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-11-13 02:03:27 +03:00
|
|
|
// Save the editor type so we can create the editor after loading uri
|
2015-05-28 18:58:42 +03:00
|
|
|
nsCString mEditorType;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mEditorFlags;
|
|
|
|
uint32_t mEditorStatus;
|
|
|
|
uint32_t mBaseCommandControllerId;
|
|
|
|
uint32_t mDocStateControllerId;
|
|
|
|
uint32_t mHTMLCommandControllerId;
|
2010-03-18 19:12:37 +03:00
|
|
|
|
|
|
|
// Make sure the docshell we use is safe
|
|
|
|
nsWeakPtr mDocShell;
|
2010-11-19 00:01:12 +03:00
|
|
|
|
|
|
|
// See if we can reuse an existing editor
|
|
|
|
nsWeakPtr mExistingEditor;
|
2001-01-26 05:16:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsEditingSession_h__
|