Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
mozInlineSpellChecker.cpp File Reference
#include "mozInlineSpellChecker.h"
#include "mozInlineSpellWordUtil.h"
#include "mozISpellI18NManager.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
#include "nsCRT.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNSRange.h"
#include "nsIDOMRange.h"
#include "nsIDOMText.h"
#include "nsIEventQueueService.h"
#include "nsIPlaintextEditor.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsISelection.h"
#include "nsISelection2.h"
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsITextServicesFilter.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "plevent.h"

Go to the source code of this file.

Classes

class  mozInlineSpellResume

Defines

#define INLINESPELL_CHECK_TIMEOUT   50
 This class is called by the editor to handle spellchecking after various events.
#define INLINESPELL_TIMEOUT_CHECK_FREQUENCY   50
#define MISSPELLED_WORD_COUNT_PENALTY   4

Functions

static PRBool ContentIsDescendantOf (nsIContent *aPossibleDescendant, nsIContent *aPossibleAncestor)
 HandleSpellCheckResumePLEvent (PLEvent *aEvent)
 DestroySpellCheckResumePLEvent (PLEvent *aEvent)

Variables

static const char kMaxSpellCheckSelectionSize [] = "extensions.spellcheck.inline.max-misspellings"

Define Documentation

This class is called by the editor to handle spellchecking after various events.

The main entrypoint is SpellCheckAfterEditorChange, which is called when the text is changed.

It is VERY IMPORTANT that we do NOT do any operations that might cause DOM notifications to be flushed when we are called from the editor. This is because the call might originate from a frame, and flushing the notifications might cause that frame to be deleted.

Using the WordUtil class to find words causes DOM notifications to be flushed because it asks for style information. As a result, we post an event and do all of the spellchecking in that event handler, which occurs later. We store all DOM pointers in ranges because they are kept up-to-date with DOM changes that may have happened while the event was on the queue.

We also allow the spellcheck to be suspended and resumed later. This makes large pastes or initializations with a lot of text not hang the browser UI.

An optimization is the mNeedsCheckAfterNavigation flag. This is set to true when we get any change, and false once there is no possibility something changed that we need to check on navigation. Navigation events tend to be a little tricky because we want to check the current word on exit if something has changed. If we navigate inside the word, we don't want to do anything. As a result, this flag is cleared in FinishNavigationEvent when we know that we are checking as a result of navigation.

Definition at line 101 of file mozInlineSpellChecker.cpp.

Definition at line 107 of file mozInlineSpellChecker.cpp.

Definition at line 114 of file mozInlineSpellChecker.cpp.


Function Documentation

PRBool ContentIsDescendantOf ( nsIContent aPossibleDescendant,
nsIContent aPossibleAncestor 
) [static]

Definition at line 1630 of file mozInlineSpellChecker.cpp.

{
  NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
  NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");

  do {
    if (aPossibleDescendant == aPossibleAncestor)
      return PR_TRUE;
    aPossibleDescendant = aPossibleDescendant->GetParent();
  } while (aPossibleDescendant);

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 500 of file mozInlineSpellChecker.cpp.

Here is the caller graph for this function:

Definition at line 491 of file mozInlineSpellChecker.cpp.

{
  mozInlineSpellResume* resume = NS_REINTERPRET_CAST(mozInlineSpellResume*,
                                                     aEvent);
  resume->mStatus.mSpellChecker->ResumeCheck(&resume->mStatus);
  return nsnull;
}

Here is the caller graph for this function:


Variable Documentation

const char kMaxSpellCheckSelectionSize[] = "extensions.spellcheck.inline.max-misspellings" [static]

Definition at line 119 of file mozInlineSpellChecker.cpp.