Back to index

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

#include <nsSVGPointList.h>

Inheritance diagram for nsSVGPointList:
Inheritance graph
[legend]
Collaboration diagram for nsSVGPointList:
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_NSIDOMSVGPOINTLIST
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)
nsIDOMSVGPointElementAt (PRInt32 index)
void AppendElement (nsIDOMSVGPoint *aElement)
void RemoveElementAt (PRInt32 index)
void InsertElementAt (nsIDOMSVGPoint *aElement, PRInt32 index)
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))
void clear ()
nsIDOMSVGPoint initialize (in nsIDOMSVGPoint newItem)
nsIDOMSVGPoint getItem (in unsigned long index)
nsIDOMSVGPoint insertItemBefore (in nsIDOMSVGPoint newItem, in unsigned long index)
nsIDOMSVGPoint replaceItem (in nsIDOMSVGPoint newItem, in unsigned long index)
nsIDOMSVGPoint removeItem (in unsigned long index)
nsIDOMSVGPoint appendItem (in nsIDOMSVGPoint newItem)

Static Public Member Functions

static nsresult Create (const nsAString &aValue, nsISVGValue **aResult)
static nsresult Create (nsIDOMSVGPointList **aResult)

Public Attributes

readonly attribute unsigned long numberOfItems

Protected Member Functions

 nsSVGPointList ()
virtual ~nsSVGPointList ()
void ReleasePoints ()
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 mPoints

Friends

class nsSVGValueAutoNotifier

Detailed Description

Definition at line 49 of file nsSVGPointList.h.


Member Enumeration Documentation

Enumerator:
mod_other 
mod_context 
mod_die 

Definition at line 68 of file nsISVGValue.h.


Constructor & Destructor Documentation

Definition at line 72 of file nsSVGPointList.cpp.

{
}

Here is the caller graph for this function:

nsSVGPointList::~nsSVGPointList ( ) [protected, virtual]

Definition at line 76 of file nsSVGPointList.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 104 of file nsSVGPointList.cpp.

{
  WillModify();
  NS_ADDREF(aElement);
  mPoints.AppendElement((void*)aElement);
  nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
  if (val)
    val->AddObserver(this);
  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:

nsresult nsSVGPointList::Create ( const nsAString &  aValue,
nsISVGValue **  aResult 
) [static]

Definition at line 50 of file nsSVGPointList.cpp.

{
  *aResult = (nsISVGValue*) new nsSVGPointList();
  if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
  
  NS_ADDREF(*aResult);

  (*aResult)->SetValueString(aValue);  
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 63 of file nsSVGPointList.cpp.

{
  *aResult = (nsIDOMSVGPointList*) new nsSVGPointList();
  if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
  
  NS_ADDREF(*aResult);
  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 360 of file nsSVGPointList.cpp.

{
  DidModify(aModType);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 98 of file nsSVGPointList.cpp.

{
  return (nsIDOMSVGPoint*)mPoints.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:

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

Definition at line 79 of file nsSVGValue.h.

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

Implements nsISVGValue.

Definition at line 218 of file nsSVGPointList.cpp.

{
  aValue.Truncate();

  PRInt32 count = mPoints.Count();

  if (count<=0) return NS_OK;

  PRInt32 i = 0;
  PRUnichar buf[48];
  
  while (1) {
    nsIDOMSVGPoint* point = ElementAt(i);
    float x, y;
    point->GetX(&x);
    point->GetY(&y);
    
    nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(PRUnichar), NS_LITERAL_STRING("%g,%g").get(), (double)x, (double)y);
    aValue.Append(buf);

    if (++i >= count) break;

    aValue.AppendLiteral(" ");
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 130 of file nsSVGPointList.cpp.

{
  WillModify();
  NS_ADDREF(aElement);
  mPoints.InsertElementAt((void*)aElement, index);
  nsCOMPtr<nsISVGValue> val = do_QueryInterface(aElement);
  if (val)
    val->AddObserver(this);
  DidModify();
}

Here is the call graph for this function:

nsIDOMSVGPoint nsIDOMSVGPointList::insertItemBefore ( in nsIDOMSVGPoint  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]
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 82 of file nsSVGPointList.cpp.

{
  WillModify();
  PRInt32 count = mPoints.Count();
  for (PRInt32 i = 0; i < count; ++i) {
    nsIDOMSVGPoint* point = ElementAt(i);
    nsCOMPtr<nsISVGValue> val = do_QueryInterface(point);
    if (val)
      val->RemoveObserver(this);
    NS_RELEASE(point);
  }
  mPoints.Clear();
  DidModify();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file nsSVGPointList.cpp.

{
  WillModify();
  nsIDOMSVGPoint* point = ElementAt(index);
  NS_ASSERTION(point, "null point");
  nsCOMPtr<nsISVGValue> val = do_QueryInterface(point);
  if (val)
    val->RemoveObserver(this);
  mPoints.RemoveElementAt(index);
  NS_RELEASE(point);
  DidModify();
}

Here is the call graph for this function:

nsIDOMSVGPoint nsIDOMSVGPointList::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:

nsIDOMSVGPoint nsIDOMSVGPointList::replaceItem ( in nsIDOMSVGPoint  newItem,
in unsigned long  index 
) [inherited]

Implements nsISVGValue.

Definition at line 161 of file nsSVGPointList.cpp.

{
  nsresult rv = NS_OK;

  char* str = ToNewCString(aValue);
  
  char* rest = str;
  char* token1;
  char* token2;
  const char* delimiters = ",\x20\x9\xD\xA";
  nsCOMArray<nsIDOMSVGPoint> points;
  
  while ( (token1 = nsCRT::strtok(rest, delimiters, &rest)) &&
          (token2 = nsCRT::strtok(rest, delimiters, &rest)) ) {

    char *end;
    
    double x = PR_strtod(token1, &end);
    if (*end != '\0') {
      rv = NS_ERROR_FAILURE;
      break; // parse error
    }
    double y = PR_strtod(token2, &end);
    if (*end != '\0') {
      rv = NS_ERROR_FAILURE;
      break; // parse error
    }
    
    nsCOMPtr<nsIDOMSVGPoint> point;
    NS_NewSVGPoint(getter_AddRefs(point), (float)x, (float)y);
    if (!point) {
      rv = NS_ERROR_OUT_OF_MEMORY;
      break;
    }
    points.AppendObject(point);
  }

  if (token1 || NS_FAILED(rv)) {
    // there was a parse error or we ran out of memory
    rv = NS_ERROR_FAILURE;
  }
  else {
    WillModify();
    ReleasePoints();
    PRInt32 count = points.Count();
    for (PRInt32 i=0; i<count; ++i) {
      AppendElement(points.ObjectAt(i));
    }
    DidModify();
  }

  nsMemory::Free(str);
  
  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 352 of file nsSVGPointList.cpp.

{
  WillModify(aModType);
  return NS_OK;
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class nsSVGValueAutoNotifier [friend, inherited]

Definition at line 59 of file nsSVGValue.h.


Member Data Documentation

nsAutoVoidArray nsSVGPointList::mPoints [protected]

Definition at line 92 of file nsSVGPointList.h.

readonly attribute unsigned long nsIDOMSVGPointList::numberOfItems [inherited]

Definition at line 46 of file nsIDOMSVGPointList.idl.


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