Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
nsSVGLength Class Reference
Inheritance diagram for nsSVGLength:
Inheritance graph
[legend]
Collaboration diagram for nsSVGLength:
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_NSIDOMSVGLENGTH
NS_IMETHOD 
SetContext (nsSVGCoordCtx *context)
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 newValueSpecifiedUnits (in unsigned short unitType, in float valueInSpecifiedUnits)
void convertToSpecifiedUnits (in unsigned short unitType)
float getTransformedValue (in nsIDOMSVGMatrix matrix)
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

const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0
const unsigned short SVG_LENGTHTYPE_NUMBER = 1
const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2
const unsigned short SVG_LENGTHTYPE_EMS = 3
const unsigned short SVG_LENGTHTYPE_EXS = 4
const unsigned short SVG_LENGTHTYPE_PX = 5
const unsigned short SVG_LENGTHTYPE_CM = 6
const unsigned short SVG_LENGTHTYPE_MM = 7
const unsigned short SVG_LENGTHTYPE_IN = 8
const unsigned short SVG_LENGTHTYPE_PT = 9
const unsigned short SVG_LENGTHTYPE_PC = 10
readonly attribute unsigned short unitType
attribute float value
attribute float valueInSpecifiedUnits
attribute DOMString valueAsString

Protected Member Functions

 nsSVGLength (float value, PRUint16 unit)
 nsSVGLength ()
virtual ~nsSVGLength ()
float mmPerPixel ()
float AxisLength ()
PRBool IsValidUnitType (PRUint16 unit)
void MaybeAddAsObserver ()
void MaybeRemoveAsObserver ()
void WillModify (modificationType aModType=mod_other)
void DidModify (modificationType aModType=mod_other)
void ReleaseObservers ()
void NotifyObservers (SVGObserverNotifyFunction f, modificationType aModType)
PRInt32 GetModifyNestCount ()

Protected Attributes

float mValueInSpecifiedUnits
PRUint16 mSpecifiedUnitType
nsRefPtr< nsSVGCoordCtxmContext

Friends

nsresult NS_NewSVGLength (nsISVGLength **result, float value, PRUint16 unit)
nsresult NS_NewSVGLength (nsISVGLength **result, const nsAString &value)
class nsSVGValueAutoNotifier

Detailed Description

Definition at line 56 of file nsSVGLength.cpp.


Member Enumeration Documentation

Enumerator:
mod_other 
mod_context 
mod_die 

Definition at line 68 of file nsISVGValue.h.


Constructor & Destructor Documentation

nsSVGLength::nsSVGLength ( float  value,
PRUint16  unit 
) [protected]

Definition at line 144 of file nsSVGLength.cpp.

    : mValueInSpecifiedUnits(value),
      mSpecifiedUnitType(unit)
{
  // we don't have a context yet, so we don't call MaybeAddAsObserver()
}
nsSVGLength::nsSVGLength ( ) [protected]

Definition at line 152 of file nsSVGLength.cpp.

{
}
nsSVGLength::~nsSVGLength ( ) [protected, virtual]

Definition at line 156 of file nsSVGLength.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:

float nsSVGLength::AxisLength ( ) [protected]

Definition at line 553 of file nsSVGLength.cpp.

{
  if (!mContext) {
    NS_WARNING("no context in AxisLength()");
    return 1.0f;
  }

  nsCOMPtr<nsIDOMSVGNumber> num = mContext->GetLength();
  NS_ASSERTION(num != nsnull, "null interface");
  float d;
  num->GetValue(&d);

  if (d == 0.0f) {
    NS_WARNING("zero axis length");
    d = 1e-20f;
  }

  return d;
}
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 nsIDOMSVGLength::convertToSpecifiedUnits ( in unsigned short  unitType) [inherited]
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 204 of file nsSVGLength.cpp.

{
  DidModify(aModType);
  return NS_OK;
}

Here is the call 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:

PRInt32 nsSVGValue::GetModifyNestCount ( ) [inline, protected, inherited]

Definition at line 79 of file nsSVGValue.h.

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

Implements nsISVGValue.

Definition at line 187 of file nsSVGLength.cpp.

{
  return GetValueAsString(aValue);
}

Definition at line 573 of file nsSVGLength.cpp.

{
  if (unit > SVG_LENGTHTYPE_UNKNOWN && unit <= SVG_LENGTHTYPE_PC)
    return PR_TRUE;

  return PR_FALSE;
}

Definition at line 581 of file nsSVGLength.cpp.

Here is the caller graph for this function:

Definition at line 590 of file nsSVGLength.cpp.

Here is the caller graph for this function:

float nsSVGLength::mmPerPixel ( ) [protected]

Definition at line 536 of file nsSVGLength.cpp.

{
  if (!mContext) {
    NS_WARNING("no context in mmPerPixel()");
    return 1.0f;
  }
  
  float mmPerPx = mContext->GetMillimeterPerPixel();

  if (mmPerPx == 0.0f) {
    NS_ASSERTION(mmPerPx != 0.0f, "invalid mm/pixels");
    mmPerPx = 1e-4f; // some small value
  }
  
  return mmPerPx;
}
void nsIDOMSVGLength::newValueSpecifiedUnits ( in unsigned short  unitType,
in float  valueInSpecifiedUnits 
) [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:

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:

Implements nsISVGLength.

Definition at line 510 of file nsSVGLength.cpp.

{
  /* Unless our unit type is SVG_LENGTHTYPE_NUMBER or SVG_LENGTHTYPE_PX, our
     user unit value is determined by our context and we must notify our
     observers that we have changed. */

  if (mSpecifiedUnitType != SVG_LENGTHTYPE_NUMBER &&
      mSpecifiedUnitType != SVG_LENGTHTYPE_PX) {
    WillModify(mod_context);
    MaybeRemoveAsObserver();
  }

  mContext = context;

  if (mSpecifiedUnitType != SVG_LENGTHTYPE_NUMBER &&
      mSpecifiedUnitType != SVG_LENGTHTYPE_PX) {
    MaybeAddAsObserver();
    DidModify(mod_context);
  }
  return NS_OK;
}

Here is the call graph for this function:

Implements nsISVGValue.

Definition at line 181 of file nsSVGLength.cpp.

{
  return SetValueAsString(aValue);
}
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 196 of file nsSVGLength.cpp.

{
  WillModify(aModType);
  return NS_OK;
}

Here is the call graph for this function:


Friends And Related Function Documentation

nsresult NS_NewSVGLength ( nsISVGLength **  result,
float  value,
PRUint16  unit 
) [friend]

Definition at line 114 of file nsSVGLength.cpp.

{
  *result = new nsSVGLength(value, unit);
  if (!*result)
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(*result);
  return NS_OK;
}
nsresult NS_NewSVGLength ( nsISVGLength **  result,
const nsAString &  value 
) [friend]

Definition at line 126 of file nsSVGLength.cpp.

{
  *result = nsnull;
  nsSVGLength *pl = new nsSVGLength();
  if (!pl)
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(pl);
  nsresult rv = pl->SetValueAsString(value);
  if (NS_FAILED(rv)) {
    NS_RELEASE(pl);
    return rv;
  }
  *result = pl;
  return NS_OK;
}  
friend class nsSVGValueAutoNotifier [friend, inherited]

Definition at line 59 of file nsSVGValue.h.


Member Data Documentation

Definition at line 106 of file nsSVGLength.cpp.

Definition at line 105 of file nsSVGLength.cpp.

Definition at line 104 of file nsSVGLength.cpp.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_CM = 6 [inherited]

Definition at line 53 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_EMS = 3 [inherited]

Definition at line 50 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_EXS = 4 [inherited]

Definition at line 51 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_IN = 8 [inherited]

Definition at line 55 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_MM = 7 [inherited]

Definition at line 54 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER = 1 [inherited]

Definition at line 48 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_PC = 10 [inherited]

Definition at line 57 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE = 2 [inherited]

Definition at line 49 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_PT = 9 [inherited]

Definition at line 56 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_PX = 5 [inherited]

Definition at line 52 of file nsIDOMSVGLength.idl.

const unsigned short nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN = 0 [inherited]

Definition at line 47 of file nsIDOMSVGLength.idl.

readonly attribute unsigned short nsIDOMSVGLength::unitType [inherited]

Definition at line 59 of file nsIDOMSVGLength.idl.

attribute float nsIDOMSVGLength::value [inherited]

Definition at line 60 of file nsIDOMSVGLength.idl.

Definition at line 64 of file nsIDOMSVGLength.idl.

Definition at line 62 of file nsIDOMSVGLength.idl.


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