Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsEditingSession.cpp File Reference
#include "nsIDOMWindow.h"
#include "nsIDOMWindowUtils.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMNSHTMLDocument.h"
#include "nsIDocument.h"
#include "nsIHTMLDocument.h"
#include "nsIDOMDocument.h"
#include "nsIURI.h"
#include "nsIScriptGlobalObject.h"
#include "nsISelectionPrivate.h"
#include "nsITransactionManager.h"
#include "nsIEditorDocShell.h"
#include "nsIDocShell.h"
#include "nsIChannel.h"
#include "nsIWebProgress.h"
#include "nsIWebNavigation.h"
#include "nsIRefreshURI.h"
#include "nsIControllers.h"
#include "nsIController.h"
#include "nsIControllerContext.h"
#include "nsICommandManager.h"
#include "nsPICommandUpdater.h"
#include "nsIPresShell.h"
#include "nsComposerCommandsUpdater.h"
#include "nsEditingSession.h"
#include "nsComponentManagerUtils.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIContentViewer.h"
#include "nsISelectionController.h"
#include "nsIPlaintextEditor.h"
#include "nsIEditor.h"
#include "nsIDOMNSDocument.h"
#include "nsIScriptContext.h"
#include "imgIContainer.h"
#include "nsPresContext.h"

Go to the source code of this file.

Defines

#define DEFAULT_EDITOR_TYPE   "html"

Functions

 NS_IMPL_ISUPPORTS4 (nsEditingSession, nsIEditingSession, nsIWebProgressListener, nsIURIContentListener, nsISupportsWeakReference) NS_IMETHODIMP nsEditingSession
PRBool IsSupportedTextType (const char *aMIMEType)

Variables

const char *const gSupportedTextTypes []

Define Documentation


Function Documentation

PRBool IsSupportedTextType ( const char *  aMIMEType)

Definition at line 270 of file nsEditingSession.cpp.

{
  if (!aMIMEType)
    return PR_FALSE;

  PRInt32 i = 0;
  while (gSupportedTextTypes[i])
  {
    if (strcmp(gSupportedTextTypes[i], aMIMEType) == 0)
    {
      return PR_TRUE;
    }

    i ++;
  }
  
  return PR_FALSE;
}

Definition at line 122 of file nsEditingSession.cpp.

{
  mEditorType.Truncate();
  mEditorFlags = 0;
  mWindowToBeEdited = do_GetWeakReference(aWindow);

  // disable plugins
  nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
  if (!docShell) return NS_ERROR_FAILURE;

  // register as a content listener, so that we can fend off URL
  // loads from sidebar
  nsresult rv;
  nsCOMPtr<nsIURIContentListener> listener = do_GetInterface(docShell, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = listener->SetParentContentListener(this);
  NS_ENSURE_SUCCESS(rv, rv);

  // Disable JavaScript in this document:
  PRBool tmp;
  rv = docShell->GetAllowJavascript(&tmp);
  NS_ENSURE_SUCCESS(rv, rv);

  mScriptsEnabled = tmp;

  rv = docShell->SetAllowJavascript(PR_FALSE);
  NS_ENSURE_SUCCESS(rv, rv);

  // Disable plugins in this document:
  rv = docShell->GetAllowPlugins(&tmp);
  NS_ENSURE_SUCCESS(rv, rv);

  mPluginsEnabled = tmp;

  rv = docShell->SetAllowPlugins(PR_FALSE);
  NS_ENSURE_SUCCESS(rv, rv);

  // Always remove existing editor
  TearDownEditorOnWindow(aWindow);
  
  // Tells embedder that startup is in progress
  mEditorStatus = eEditorCreationInProgress;

  //temporary to set editor type here. we will need different classes soon.
  if (!aEditorType)
    aEditorType = DEFAULT_EDITOR_TYPE;
  mEditorType = aEditorType;

  // if all this does is setup listeners and I don't need listeners, 
  // can't this step be ignored?? (based on aDoAfterURILoad)
  rv = PrepareForEditing(aWindow);
  if (NS_FAILED(rv)) return rv;  
  
  nsCOMPtr<nsIEditorDocShell> editorDocShell;
  rv = GetEditorDocShellFromWindow(aWindow, getter_AddRefs(editorDocShell));
  if (NS_FAILED(rv)) return rv;  
  
  // set the flag on the docShell to say that it's editable
  rv = editorDocShell->MakeEditable(aDoAfterUriLoad);
  if (NS_FAILED(rv)) return rv;  

  // Setup commands common to plaintext and html editors,
  //  including the document creation observers
  // the first is an editor controller
  rv = SetupEditorCommandController("@mozilla.org/editor/editorcontroller;1",
                                    aWindow,
                                    NS_STATIC_CAST(nsIEditingSession*, this),
                                    &mBaseCommandControllerId);
  if (NS_FAILED(rv)) return rv;

  // The second is a controller to monitor doc state,
  // such as creation and "dirty flag"
  rv = SetupEditorCommandController("@mozilla.org/editor/editordocstatecontroller;1",
                                    aWindow,
                                    NS_STATIC_CAST(nsIEditingSession*, this),
                                    &mDocStateControllerId);
  if (NS_FAILED(rv)) return rv;

  // aDoAfterUriLoad can be false only when making an existing window editable
  if (!aDoAfterUriLoad)
  {
    rv = SetupEditorOnWindow(aWindow);

    // mEditorStatus is set to the error reason
    // Since this is used only when editing an existing page,
    //  it IS ok to destroy current editor
    if (NS_FAILED(rv))
      TearDownEditorOnWindow(aWindow);
  }
  return rv;
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
  "text/plain",
  "text/css",
  "text/rdf",
  "text/xsl",
  "text/javascript",           
  "text/ecmascript",           
  "application/javascript",
  "application/ecmascript",
  "application/x-javascript",  
  "text/xul",                  
  "application/vnd.mozilla.xul+xml",
  NULL      
}

Definition at line 254 of file nsEditingSession.cpp.