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__
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef nsWeakReference_h__
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsWeakReference.h" // for nsSupportsWeakReference, etc
|
2001-01-26 05:16:14 +03:00
|
|
|
#endif
|
|
|
|
|
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;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIDOMWindow;
|
|
|
|
class nsISupports;
|
|
|
|
class nsITimer;
|
2001-04-06 03:57:22 +04:00
|
|
|
|
2001-01-26 05:16:14 +03:00
|
|
|
#define NS_EDITINGSESSION_CID \
|
|
|
|
{ 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } }
|
|
|
|
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsComposerCommandsUpdater;
|
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 nsIEditor;
|
|
|
|
class nsIWebProgress;
|
2001-04-06 03:57:22 +04:00
|
|
|
|
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
|
|
|
|
|
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsEditingSession();
|
2001-01-26 05:16:14 +03:00
|
|
|
|
2002-11-13 02:03:27 +03:00
|
|
|
nsresult SetupEditorCommandController(const char *aControllerClassName,
|
2016-01-30 20:05:36 +03:00
|
|
|
mozIDOMWindowProxy* aWindow,
|
2003-04-10 22:44:03 +04:00
|
|
|
nsISupports *aContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t *aControllerId);
|
2004-01-19 23:31:18 +03:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
nsresult SetContextOnControllerById(nsIControllers* aControllers,
|
2003-04-10 22:44:03 +04:00
|
|
|
nsISupports* aContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aID);
|
2001-01-26 05:16:14 +03:00
|
|
|
|
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);
|
2015-05-28 18:58:42 +03:00
|
|
|
nsresult EndDocumentLoad(nsIWebProgress *aWebProgress,
|
2003-02-27 17:06:29 +03:00
|
|
|
nsIChannel* aChannel, nsresult aStatus,
|
2011-09-29 10:19:26 +04:00
|
|
|
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,
|
2002-11-13 02:03:27 +03:00
|
|
|
nsIChannel* aChannel, nsresult aStatus);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsProgressForTargetDocument(nsIWebProgress *aWebProgress);
|
2001-04-06 03:57:22 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void RemoveEditorControllers(nsPIDOMWindowOuter* aWindow);
|
|
|
|
void RemoveWebProgressListener(nsPIDOMWindowOuter* aWindow);
|
|
|
|
void RestoreAnimationMode(nsPIDOMWindowOuter* aWindow);
|
|
|
|
void RemoveListenersAndControllers(nsPIDOMWindowOuter* aWindow,
|
2008-04-24 01:36:17 +04:00
|
|
|
nsIEditor *aEditor);
|
|
|
|
|
2001-01-26 05:16:14 +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
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsComposerCommandsUpdater> mStateMaintainer;
|
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__
|