Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
TypeInState Class Reference

#include <TypeInState.h>

Inheritance diagram for TypeInState:
Inheritance graph
[legend]
Collaboration diagram for TypeInState:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS TypeInState ()
void Reset ()
virtual ~TypeInState ()
nsresult UpdateSelState (nsISelection *aSelection)
NS_DECL_NSISELECTIONLISTENER
nsresult 
SetProp (nsIAtom *aProp)
nsresult SetProp (nsIAtom *aProp, const nsString &aAttr)
nsresult SetProp (nsIAtom *aProp, const nsString &aAttr, const nsString &aValue)
nsresult ClearAllProps ()
nsresult ClearProp (nsIAtom *aProp)
nsresult ClearProp (nsIAtom *aProp, const nsString &aAttr)
nsresult TakeClearProperty (PropItem **outPropItem)
nsresult TakeSetProperty (PropItem **outPropItem)
nsresult TakeRelativeFontSize (PRInt32 *outRelSize)
nsresult GetTypingState (PRBool &isSet, PRBool &theSetting, nsIAtom *aProp)
nsresult GetTypingState (PRBool &isSet, PRBool &theSetting, nsIAtom *aProp, const nsString &aAttr)
nsresult GetTypingState (PRBool &isSet, PRBool &theSetting, nsIAtom *aProp, const nsString &aAttr, nsString *outValue)
void notifySelectionChanged (in nsIDOMDocument doc, in nsISelection sel, in short reason)

Static Public Member Functions

static PRBool FindPropInList (nsIAtom *aProp, const nsAString &aAttr, nsAString *outValue, nsVoidArray &aList, PRInt32 &outIndex)

Public Attributes

const short NO_REASON = 0
const short DRAG_REASON = 1
const short MOUSEDOWN_REASON = 2
const short MOUSEUP_REASON = 4
const short KEYPRESS_REASON = 8
const short SELECTALL_REASON = 16

Protected Member Functions

nsresult RemovePropFromSetList (nsIAtom *aProp, const nsString &aAttr)
nsresult RemovePropFromClearedList (nsIAtom *aProp, const nsString &aAttr)
PRBool IsPropSet (nsIAtom *aProp, const nsString &aAttr, nsString *outValue)
PRBool IsPropSet (nsIAtom *aProp, const nsString &aAttr, nsString *outValue, PRInt32 &outIndex)
PRBool IsPropCleared (nsIAtom *aProp, const nsString &aAttr)
PRBool IsPropCleared (nsIAtom *aProp, const nsString &aAttr, PRInt32 &outIndex)

Protected Attributes

nsVoidArray mSetArray
nsVoidArray mClearedArray
PRInt32 mRelativeFontSize
nsCOMPtr< nsIDOMNodemLastSelectionContainer
PRInt32 mLastSelectionOffset

Friends

class nsHTMLEditRules

Detailed Description

Definition at line 60 of file TypeInState.h.


Constructor & Destructor Documentation

Definition at line 53 of file TypeInState.cpp.

Definition at line 62 of file TypeInState.cpp.

{
  // Call Reset() to release any data that may be in
  // mClearedArray and mSetArray.

  Reset();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 209 of file TypeInState.cpp.

{
  // null prop means "all" props
  return ClearProp(nsnull,EmptyString());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 215 of file TypeInState.cpp.

{
  return ClearProp(aProp,EmptyString());
}

Here is the caller graph for this function:

Definition at line 220 of file TypeInState.cpp.

{
  // if it's already cleared we are done
  if (IsPropCleared(aProp,aAttr)) return NS_OK;
  
  // make a new propitem
  PropItem *item = new PropItem(aProp,aAttr,EmptyString());
  if (!item) return NS_ERROR_OUT_OF_MEMORY;
  
  // remove it from the list of set properties, if we have a match
  RemovePropFromSetList(aProp,aAttr);
  
  // add it to the list of cleared properties
  mClearedArray.AppendElement((void*)item);
  
  return NS_OK;
}

Here is the call graph for this function:

PRBool TypeInState::FindPropInList ( nsIAtom aProp,
const nsAString &  aAttr,
nsAString *  outValue,
nsVoidArray aList,
PRInt32 outIndex 
) [static]

Definition at line 425 of file TypeInState.cpp.

{
  // linear search.  list should be short.
  PRInt32 i, count = aList.Count();
  for (i=0; i<count; i++)
  {
    PropItem *item = (PropItem*)aList[i];
    if ( (item->tag == aProp) &&
         (item->attr == aAttr) ) 
    {
      if (outValue) *outValue = item->value;
      outIndex = i;
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the caller graph for this function:

nsresult TypeInState::GetTypingState ( PRBool isSet,
PRBool theSetting,
nsIAtom aProp 
)

Definition at line 286 of file TypeInState.cpp.

{
  return GetTypingState(isSet, theSetting, aProp, EmptyString(), nsnull);
}

Here is the caller graph for this function:

nsresult TypeInState::GetTypingState ( PRBool isSet,
PRBool theSetting,
nsIAtom aProp,
const nsString aAttr 
)

Definition at line 291 of file TypeInState.cpp.

{
  return GetTypingState(isSet, theSetting, aProp, aAttr, nsnull);
}

Here is the call graph for this function:

nsresult TypeInState::GetTypingState ( PRBool isSet,
PRBool theSetting,
nsIAtom aProp,
const nsString aAttr,
nsString outValue 
)

Definition at line 300 of file TypeInState.cpp.

{
  if (IsPropSet(aProp, aAttr, aValue))
  {
    isSet = PR_TRUE;
    theSetting = PR_TRUE;
  }
  else if (IsPropCleared(aProp, aAttr))
  {
    isSet = PR_TRUE;
    theSetting = PR_FALSE;
  }
  else
  {
    isSet = PR_FALSE;
  }
  return NS_OK;
}

Here is the call graph for this function:

PRBool TypeInState::IsPropCleared ( nsIAtom aProp,
const nsString aAttr 
) [protected]

Definition at line 402 of file TypeInState.cpp.

{
  PRInt32 i;
  return IsPropCleared(aProp, aAttr, i);
}

Here is the caller graph for this function:

PRBool TypeInState::IsPropCleared ( nsIAtom aProp,
const nsString aAttr,
PRInt32 outIndex 
) [protected]

Definition at line 410 of file TypeInState.cpp.

{
  if (FindPropInList(aProp, aAttr, nsnull, mClearedArray, outIndex))
    return PR_TRUE;
  if (FindPropInList(0, EmptyString(), nsnull, mClearedArray, outIndex))
  {
    // special case for all props cleared
    outIndex = -1;
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

PRBool TypeInState::IsPropSet ( nsIAtom aProp,
const nsString aAttr,
nsString outValue 
) [protected]

Definition at line 371 of file TypeInState.cpp.

{
  PRInt32 i;
  return IsPropSet(aProp, aAttr, outValue, i);
}

Here is the caller graph for this function:

PRBool TypeInState::IsPropSet ( nsIAtom aProp,
const nsString aAttr,
nsString outValue,
PRInt32 outIndex 
) [protected]

Definition at line 380 of file TypeInState.cpp.

{
  // linear search.  list should be short.
  PRInt32 i, count = mSetArray.Count();
  for (i=0; i<count; i++)
  {
    PropItem *item = (PropItem*)mSetArray[i];
    if ( (item->tag == aProp) &&
         (item->attr == aAttr) )
    {
      if (outValue) *outValue = item->value;
      outIndex = i;
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}
void nsISelectionListener::notifySelectionChanged ( in nsIDOMDocument  doc,
in nsISelection  sel,
in short  reason 
) [inherited]
nsresult TypeInState::RemovePropFromClearedList ( nsIAtom aProp,
const nsString aAttr 
) [protected]

Definition at line 357 of file TypeInState.cpp.

{
  PRInt32 index;
  if (FindPropInList(aProp, aAttr, nsnull, mClearedArray, index))
  {
    PropItem *item = (PropItem*)mClearedArray.ElementAt(index);
    mClearedArray.RemoveElementAt(index);
    if (item) delete item;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult TypeInState::RemovePropFromSetList ( nsIAtom aProp,
const nsString aAttr 
) [protected]

Definition at line 329 of file TypeInState.cpp.

{
  PRInt32 index;
  PropItem *item;
  if (!aProp)
  {
    // clear _all_ props
    mRelativeFontSize=0;
    while ((index = mSetArray.Count()))
    {
      // go backwards to keep nsVoidArray from memmoving everything each time
      index--; // nsVoidArray is zero based
      item = (PropItem*)mSetArray.ElementAt(index);
      mSetArray.RemoveElementAt(index);
      if (item) delete item;
    }
  }
  else if (FindPropInList(aProp, aAttr, nsnull, mSetArray, index))
  {
    item = (PropItem*)mSetArray.ElementAt(index);
    mSetArray.RemoveElementAt(index);
    if (item) delete item;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 135 of file TypeInState.cpp.

{
  PRInt32 count;
  PropItem *propItemPtr;
  
  while ((count = mClearedArray.Count()))
  {
    // go backwards to keep nsVoidArray from memmoving everything each time
    count--; // nsVoidArray is zero based
    propItemPtr = (PropItem*)mClearedArray.ElementAt(count);
    mClearedArray.RemoveElementAt(count);
    if (propItemPtr) delete propItemPtr;
  }
  while ((count = mSetArray.Count()))
  {
    // go backwards to keep nsVoidArray from memmoving everything each time
    count--; // nsVoidArray is zero based
    propItemPtr = (PropItem*)mSetArray.ElementAt(count);
    mSetArray.RemoveElementAt(count);
    if (propItemPtr) delete propItemPtr;
  }
}

Here is the caller graph for this function:

Definition at line 159 of file TypeInState.cpp.

{
  return SetProp(aProp,EmptyString(),EmptyString());
}

Here is the caller graph for this function:

nsresult TypeInState::SetProp ( nsIAtom aProp,
const nsString aAttr 
)

Definition at line 164 of file TypeInState.cpp.

{
  return SetProp(aProp,aAttr,EmptyString());
}

Here is the call graph for this function:

nsresult TypeInState::SetProp ( nsIAtom aProp,
const nsString aAttr,
const nsString aValue 
)

Definition at line 169 of file TypeInState.cpp.

{
  // special case for big/small, these nest
  if (nsEditProperty::big == aProp)
  {
    mRelativeFontSize++;
    return NS_OK;
  }
  if (nsEditProperty::small == aProp)
  {
    mRelativeFontSize--;
    return NS_OK;
  }

  PRInt32 index;
  PropItem *item;

  if (IsPropSet(aProp,aAttr,nsnull,index))
  {
    // if it's already set, update the value
    item = (PropItem*)mSetArray[index];
    item->value = aValue;
  }
  else 
  {
    // make a new propitem
    item = new PropItem(aProp,aAttr,aValue);
    if (!item) return NS_ERROR_OUT_OF_MEMORY;
    
    // add it to the list of set properties
    mSetArray.AppendElement((void*)item);
    
    // remove it from the list of cleared properties, if we have a match
    RemovePropFromClearedList(aProp,aAttr);  
  }
    
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 243 of file TypeInState.cpp.

{
  if (!outPropItem) return NS_ERROR_NULL_POINTER;
  *outPropItem = nsnull;
  PRInt32 count = mClearedArray.Count();
  if (count) // go backwards to keep nsVoidArray from memmoving everything each time
  {
    count--; // nsVoidArray is zero based
    *outPropItem = (PropItem*)mClearedArray[count];
    mClearedArray.RemoveElementAt(count);
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 278 of file TypeInState.cpp.

{
  if (!outRelSize) return NS_ERROR_NULL_POINTER;
  *outRelSize = mRelativeFontSize;
  mRelativeFontSize = 0;
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 261 of file TypeInState.cpp.

{
  if (!outPropItem) return NS_ERROR_NULL_POINTER;
  *outPropItem = nsnull;
  PRInt32 count = mSetArray.Count();
  if (count) // go backwards to keep nsVoidArray from memmoving everything each time
  {
    count--; // nsVoidArray is zero based
    *outPropItem = (PropItem*)mSetArray[count];
    mSetArray.RemoveElementAt(count);
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 70 of file TypeInState.cpp.

{
  if (!aSelection) return NS_ERROR_NULL_POINTER;
  
  PRBool isCollapsed = PR_FALSE;
  nsresult result = aSelection->GetIsCollapsed(&isCollapsed);

  if (NS_FAILED(result)) return result;

  if (isCollapsed)
  {
    result = nsEditor::GetStartNodeAndOffset(aSelection, address_of(mLastSelectionContainer), &mLastSelectionOffset);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsHTMLEditRules [friend]

Definition at line 121 of file TypeInState.h.


Member Data Documentation

Definition at line 47 of file nsISelectionListener.idl.

Definition at line 50 of file nsISelectionListener.idl.

Definition at line 116 of file TypeInState.h.

Definition at line 118 of file TypeInState.h.

Definition at line 119 of file TypeInState.h.

Definition at line 48 of file nsISelectionListener.idl.

Definition at line 49 of file nsISelectionListener.idl.

Definition at line 117 of file TypeInState.h.

Definition at line 115 of file TypeInState.h.

const short nsISelectionListener::NO_REASON = 0 [inherited]

Definition at line 46 of file nsISelectionListener.idl.

Definition at line 51 of file nsISelectionListener.idl.


The documentation for this class was generated from the following files: