Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
nsSVGNumberList Class Reference
Inheritance diagram for nsSVGNumberList:
Inheritance graph
[legend]
Collaboration diagram for nsSVGNumberList:
Collaboration graph
[legend]

List of all members.

Public Types

enum  modificationType { mod_other = 0, mod_context, mod_die }

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIDOMSVGNUMBERLIST
NS_IMETHOD 
SetValueString (const nsAString &aValue)
NS_IMETHOD GetValueString (nsAString &aValue)
NS_IMETHOD WillModifySVGObservable (nsISVGValue *observable, modificationType aModType)
NS_IMETHOD DidModifySVGObservable (nsISVGValue *observable, modificationType aModType)
void clear ()
nsIDOMSVGNumber initialize (in nsIDOMSVGNumber newItem)
nsIDOMSVGNumber getItem (in unsigned long index)
nsIDOMSVGNumber insertItemBefore (in nsIDOMSVGNumber newItem, in unsigned long index)
nsIDOMSVGNumber replaceItem (in nsIDOMSVGNumber newItem, in unsigned long index)
nsIDOMSVGNumber removeItem (in unsigned long index)
nsIDOMSVGNumber appendItem (in nsIDOMSVGNumber newItem)
NS_IMETHOD AddObserver (nsISVGValueObserver *observer)
NS_IMETHOD RemoveObserver (nsISVGValueObserver *observer)
NS_IMETHOD BeginBatchUpdate ()
NS_IMETHOD EndBatchUpdate ()
typedef NS_STDCALL_FUNCPROTO (nsresult, SVGObserverNotifyFunction, nsISVGValueObserver, DidModifySVGObservable,(nsISVGValue *, nsISVGValue::modificationType))

Public Attributes

readonly attribute unsigned long numberOfItems

Protected Member Functions

 nsSVGNumberList ()
 ~nsSVGNumberList ()
nsIDOMSVGNumberElementAt (PRInt32 index)
void AppendElement (nsIDOMSVGNumber *aElement)
void RemoveElementAt (PRInt32 index)
nsresult InsertElementAt (nsIDOMSVGNumber *aElement, PRInt32 index)
void ReleaseNumbers ()
void WillModify (modificationType aModType=mod_other)
void DidModify (modificationType aModType=mod_other)
void ReleaseObservers ()
void NotifyObservers (SVGObserverNotifyFunction f, modificationType aModType)
PRInt32 GetModifyNestCount ()

Protected Attributes

nsAutoVoidArray mNumbers

Friends

nsresult NS_NewSVGNumberList (nsIDOMSVGNumberList **result)
class nsSVGValueAutoNotifier

Detailed Description

Definition at line 54 of file nsSVGNumberList.cpp.


Member Enumeration Documentation

Enumerator:
mod_other 
mod_context 
mod_die 

Definition at line 68 of file nsISVGValue.h.


Constructor & Destructor Documentation

Definition at line 102 of file nsSVGNumberList.cpp.

{
}

Definition at line 106 of file nsSVGNumberList.cpp.

Here is the call graph for this function:


Member Function Documentation

NS_IMETHODIMP nsSVGValue::AddObserver ( nsISVGValueObserver observer) [virtual, inherited]

Implements nsISVGValue.

Definition at line 97 of file nsSVGValue.cpp.

{
  nsIWeakReference* wr = NS_GetWeakReference(observer);
  if (!wr) return NS_ERROR_FAILURE;
  mObservers.AppendElement((void*)wr);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 349 of file nsSVGNumberList.cpp.

{
  WillModify();
  NS_ADDREF(aElement);
  
  // The SVG specs state that 'if newItem is already in a list, it
  // is removed from its previous list before it is inserted into this
  // list':
  //  aElement->SetListOwner(this);
  
  mNumbers.AppendElement((void*)aElement);
  NS_ADD_SVGVALUE_OBSERVER(aElement);
  DidModify();
}

Here is the call graph for this function:

NS_IMETHODIMP nsSVGValue::BeginBatchUpdate ( ) [virtual, inherited]

Implements nsISVGValue.

Definition at line 119 of file nsSVGValue.cpp.

{
  WillModify();
  return NS_OK;
}

Here is the call graph for this function:

void nsSVGValue::DidModify ( modificationType  aModType = mod_other) [protected, inherited]

Definition at line 86 of file nsSVGValue.cpp.

{
  NS_ASSERTION(mModifyNestCount>0, "unbalanced Will/DidModify calls");
  if (--mModifyNestCount == 0) {
    OnDidModify();
    NotifyObservers(&nsISVGValueObserver::DidModifySVGObservable, aModType);
  }
}

Here is the call graph for this function:

Implements nsISVGValueObserver.

Definition at line 318 of file nsSVGNumberList.cpp.

{
  DidModify(aModType);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 343 of file nsSVGNumberList.cpp.

{
  return (nsIDOMSVGNumber*)mNumbers.ElementAt(index);
}

Here is the caller graph for this function:

NS_IMETHODIMP nsSVGValue::EndBatchUpdate ( ) [virtual, inherited]

Implements nsISVGValue.

Definition at line 126 of file nsSVGValue.cpp.

{
  DidModify();
  return NS_OK;
}

Here is the call graph for this function:

nsIDOMSVGNumber nsIDOMSVGNumberList::getItem ( in unsigned long  index) [inherited]
PRInt32 nsSVGValue::GetModifyNestCount ( ) [inline, protected, inherited]

Definition at line 79 of file nsSVGValue.h.

{ return mModifyNestCount; }
NS_IMETHODIMP nsSVGNumberList::GetValueString ( nsAString &  aValue) [virtual]

Implements nsISVGValue.

Definition at line 165 of file nsSVGNumberList.cpp.

{
  aValue.Truncate();

  PRInt32 count = mNumbers.Count();

  if (count<=0) return NS_OK;

  PRInt32 i = 0;
  
  while (1) {
    nsIDOMSVGNumber* number = ElementAt(i);
    nsCOMPtr<nsISVGValue> val = do_QueryInterface(number);
    NS_ASSERTION(val, "number doesn't implement required interface");
    if (!val) continue;
    nsAutoString str;
    val->GetValueString(str);
    aValue.Append(str);

    if (++i >= count) break;

    aValue.Append(NS_LITERAL_STRING(" "));
  }
  
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsSVGNumberList::InsertElementAt ( nsIDOMSVGNumber aElement,
PRInt32  index 
) [protected]

Definition at line 377 of file nsSVGNumberList.cpp.

{
  nsresult rv;
  WillModify();
  NS_ADDREF(aElement);

  // The SVG specs state that 'if newItem is already in a list, it
  // is removed from its previous list before it is inserted into this
  // list':
  //  aElement->SetListOwner(this);
  
  if (!NS_FAILED(rv = mNumbers.InsertElementAt((void*)aElement, index)))
    NS_ADD_SVGVALUE_OBSERVER(aElement);
  DidModify();
  return rv;
}

Here is the call graph for this function:

nsIDOMSVGNumber nsIDOMSVGNumberList::insertItemBefore ( in nsIDOMSVGNumber  newItem,
in unsigned long  index 
) [inherited]
void nsSVGValue::NotifyObservers ( SVGObserverNotifyFunction  f,
modificationType  aModType 
) [protected, inherited]

Definition at line 66 of file nsSVGValue.cpp.

{
  PRInt32 count = mObservers.Count();
  for (PRInt32 i = 0; i < count; ++i) {
    nsIWeakReference* wr = NS_STATIC_CAST(nsIWeakReference*,mObservers.ElementAt(i));
    nsCOMPtr<nsISVGValueObserver> observer = do_QueryReferent(wr);
    if (observer)
       (NS_STATIC_CAST(nsISVGValueObserver*,observer)->*f)(this, aModType);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

typedef nsSVGValue::NS_STDCALL_FUNCPROTO ( nsresult  ,
SVGObserverNotifyFunction  ,
nsISVGValueObserver  ,
DidModifySVGObservable  ,
(nsISVGValue *, nsISVGValue::modificationType  
) [inherited]

Definition at line 329 of file nsSVGNumberList.cpp.

{
  WillModify();
  PRInt32 count = mNumbers.Count();
  for (PRInt32 i = 0; i < count; ++i) {
    nsIDOMSVGNumber* number = ElementAt(i);
    NS_REMOVE_SVGVALUE_OBSERVER(number);
    NS_RELEASE(number);
  }
  mNumbers.Clear();
  DidModify();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSVGValue::ReleaseObservers ( ) [protected, inherited]

Definition at line 53 of file nsSVGValue.cpp.

{
  PRInt32 count = mObservers.Count();
  PRInt32 i;
  for (i = 0; i < count; ++i) {
    nsIWeakReference* wr = NS_STATIC_CAST(nsIWeakReference*,mObservers.ElementAt(i));
    NS_RELEASE(wr);
  }
  while (i)
    mObservers.RemoveElementAt(--i);
}

Here is the caller graph for this function:

Definition at line 365 of file nsSVGNumberList.cpp.

{
  WillModify();
  nsIDOMSVGNumber* number = ElementAt(index);
  NS_ASSERTION(number, "null number");
  NS_REMOVE_SVGVALUE_OBSERVER(number);
  mNumbers.RemoveElementAt(index);
  NS_RELEASE(number);
  DidModify();
}

Here is the call graph for this function:

nsIDOMSVGNumber nsIDOMSVGNumberList::removeItem ( in unsigned long  index) [inherited]
NS_IMETHODIMP nsSVGValue::RemoveObserver ( nsISVGValueObserver observer) [virtual, inherited]

Implements nsISVGValue.

Definition at line 106 of file nsSVGValue.cpp.

{
  nsCOMPtr<nsIWeakReference> wr = do_GetWeakReference(observer);
  if (!wr) return NS_ERROR_FAILURE;
  PRInt32 i = mObservers.IndexOf((void*)wr);
  if (i<0) return NS_ERROR_FAILURE;
  nsIWeakReference* wr2 = NS_STATIC_CAST(nsIWeakReference*,mObservers.ElementAt(i));
  NS_RELEASE(wr2);
  mObservers.RemoveElementAt(i);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMSVGNumber nsIDOMSVGNumberList::replaceItem ( in nsIDOMSVGNumber  newItem,
in unsigned long  index 
) [inherited]

Implements nsISVGValue.

Definition at line 130 of file nsSVGNumberList.cpp.

{
  WillModify();
  ReleaseNumbers();

  nsresult rv = NS_OK;

  char* str;
  str = ToNewCString(aValue);

  char* rest = str;
  char* token;
  const char* delimiters = ", \t\r\n";

  while ((token = nsCRT::strtok(rest, delimiters, &rest))) {
    char *left;
    double value = PR_strtod(token, &left);
    if (token!=left) {
      nsCOMPtr<nsIDOMSVGNumber> number;
      NS_NewSVGNumber(getter_AddRefs(number), float(value));
      if (!number) {
        rv = NS_ERROR_FAILURE;
        break;
      }
      AppendElement(number);
    }
  }
  
  nsMemory::Free(str);
  
  DidModify();
  return rv;
}

Here is the call graph for this function:

void nsSVGValue::WillModify ( modificationType  aModType = mod_other) [protected, inherited]

Definition at line 79 of file nsSVGValue.cpp.

Here is the call graph for this function:

Implements nsISVGValueObserver.

Definition at line 310 of file nsSVGNumberList.cpp.

{
  WillModify(aModType);
  return NS_OK;
}

Here is the call graph for this function:


Friends And Related Function Documentation

Definition at line 399 of file nsSVGNumberList.cpp.

{
  *result = nsnull;
  
  nsSVGNumberList* numberList = new nsSVGNumberList();
  if (!numberList) return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(numberList);

  *result = numberList;
  
  return NS_OK;
}
friend class nsSVGValueAutoNotifier [friend, inherited]

Definition at line 59 of file nsSVGValue.h.


Member Data Documentation

nsAutoVoidArray nsSVGNumberList::mNumbers [protected]

Definition at line 95 of file nsSVGNumberList.cpp.

readonly attribute unsigned long nsIDOMSVGNumberList::numberOfItems [inherited]

Definition at line 46 of file nsIDOMSVGNumberList.idl.


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