Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
nsSVGPreserveAspectRatio Class Reference
Inheritance diagram for nsSVGPreserveAspectRatio:
Inheritance graph
[legend]
Collaboration diagram for nsSVGPreserveAspectRatio:
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_NSIDOMSVGPRESERVEASPECTRATIO
NS_IMETHOD 
SetValueString (const nsAString &aValue)
NS_IMETHOD GetValueString (nsAString &aValue)
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_PRESERVEASPECTRATIO_UNKNOWN = 0
const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1
const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMIN = 2
const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3
const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4
const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMID = 5
const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMID = 6
const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMID = 7
const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMAX = 8
const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9
const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
const unsigned short SVG_MEETORSLICE_UNKNOWN = 0
const unsigned short SVG_MEETORSLICE_MEET = 1
const unsigned short SVG_MEETORSLICE_SLICE = 2
attribute unsigned short align
attribute unsigned short meetOrSlice

Protected Member Functions

 nsSVGPreserveAspectRatio (PRUint16 aAlign, PRUint16 aMeetOrSlice)
 ~nsSVGPreserveAspectRatio ()
void WillModify (modificationType aModType=mod_other)
void DidModify (modificationType aModType=mod_other)
void ReleaseObservers ()
void NotifyObservers (SVGObserverNotifyFunction f, modificationType aModType)
PRInt32 GetModifyNestCount ()

Protected Attributes

PRUint16 mAlign
PRUint16 mMeetOrSlice

Friends

nsresult NS_NewSVGPreserveAspectRatio (nsIDOMSVGPreserveAspectRatio **result, PRUint16 aAlign, PRUint16 aMeetOrSlice)
class nsSVGValueAutoNotifier

Detailed Description

Definition at line 47 of file nsSVGPreserveAspectRatio.cpp.


Member Enumeration Documentation

Enumerator:
mod_other 
mod_context 
mod_die 

Definition at line 68 of file nsISVGValue.h.


Constructor & Destructor Documentation

nsSVGPreserveAspectRatio::nsSVGPreserveAspectRatio ( PRUint16  aAlign,
PRUint16  aMeetOrSlice 
) [protected]

Definition at line 78 of file nsSVGPreserveAspectRatio.cpp.

    : mAlign(aAlign), mMeetOrSlice(aMeetOrSlice)
{
}

Definition at line 84 of file nsSVGPreserveAspectRatio.cpp.

{
}

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:

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:

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 nsSVGPreserveAspectRatio::GetValueString ( nsAString &  aValue) [virtual]

Implements nsISVGValue.

Definition at line 180 of file nsSVGPreserveAspectRatio.cpp.

{
  // XXX: defer isn't stored

  switch (mAlign) {
    case SVG_PRESERVEASPECTRATIO_NONE:
      aValue.AssignLiteral("none");
      break;
    case SVG_PRESERVEASPECTRATIO_XMINYMIN:
      aValue.AssignLiteral("xMinYMin");
      break;
    case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
      aValue.AssignLiteral("xMidYMin");
      break;
    case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
      aValue.AssignLiteral("xMaxYMin");
      break;
    case SVG_PRESERVEASPECTRATIO_XMINYMID:
      aValue.AssignLiteral("xMinYMid");
      break;
    case SVG_PRESERVEASPECTRATIO_XMIDYMID:
      aValue.AssignLiteral("xMidYMid");
      break;
    case SVG_PRESERVEASPECTRATIO_XMAXYMID:
      aValue.AssignLiteral("xMaxYMid");
      break;
    case SVG_PRESERVEASPECTRATIO_XMINYMAX:
      aValue.AssignLiteral("xMinYMax");
      break;
    case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
      aValue.AssignLiteral("xMidYMax");
      break;
    case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
      aValue.AssignLiteral("xMaxYMax");
      break;
    default:
      NS_NOTREACHED("Unknown value for mAlign");
  }

  // XXX: meetOrSlice may not have been specified in the attribute

  if (mAlign != SVG_PRESERVEASPECTRATIO_NONE) {
    switch (mMeetOrSlice) {
      case SVG_MEETORSLICE_MEET:
        aValue.AppendLiteral(" meet");
        break;
      case SVG_MEETORSLICE_SLICE:
        aValue.AppendLiteral(" slice");
        break;
      default:
        NS_NOTREACHED("Unknown value for mMeetOrSlice");
    }
  }

  return NS_OK;
}
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 nsISVGValue.

Definition at line 105 of file nsSVGPreserveAspectRatio.cpp.

{
  char* str = ToNewCString(aValue);
  if (!str) return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv = NS_OK;

  char* rest = str;
  char* token;
  const char* delimiters = "\x20\x9\xD\xA";
  PRUint16 align, meetOrSlice;

  token = nsCRT::strtok(rest, delimiters, &rest);

  if (token && !strcmp(token, "defer"))
    // Ignore: only applicable for preserveAspectRatio on 'image' elements
    token = nsCRT::strtok(rest, delimiters, &rest);

  if (token) {
    if (!strcmp(token, "none"))
      align = SVG_PRESERVEASPECTRATIO_NONE;
    else if (!strcmp(token, "xMinYMin"))
      align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
    else if (!strcmp(token, "xMidYMin"))
      align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
    else if (!strcmp(token, "xMaxYMin"))
      align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
    else if (!strcmp(token, "xMinYMid"))
      align = SVG_PRESERVEASPECTRATIO_XMINYMID;
    else if (!strcmp(token, "xMidYMid"))
      align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
    else if (!strcmp(token, "xMaxYMid"))
      align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
    else if (!strcmp(token, "xMinYMax"))
      align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
    else if (!strcmp(token, "xMidYMax"))
      align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
    else if (!strcmp(token, "xMaxYMax"))
      align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
    else
      rv = NS_ERROR_FAILURE;

    if (NS_SUCCEEDED(rv)) {
      token = nsCRT::strtok(rest, delimiters, &rest);
      if (token) {
        if (!strcmp(token, "meet"))
          meetOrSlice = SVG_MEETORSLICE_MEET;
        else if (!strcmp(token, "slice"))
          meetOrSlice = SVG_MEETORSLICE_SLICE;
        else
          rv = NS_ERROR_FAILURE;
      }
      else
        meetOrSlice = SVG_MEETORSLICE_MEET;
    }
  }
  else  // align not specified
    rv = NS_ERROR_FAILURE;

  if (nsCRT::strtok(rest, delimiters, &rest))  // there's more
    rv = NS_ERROR_FAILURE;

  if (NS_SUCCEEDED(rv)) {
    WillModify();
    mAlign = align;
    mMeetOrSlice = meetOrSlice;
    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:


Friends And Related Function Documentation

nsresult NS_NewSVGPreserveAspectRatio ( nsIDOMSVGPreserveAspectRatio **  result,
PRUint16  aAlign,
PRUint16  aMeetOrSlice 
) [friend]

Definition at line 283 of file nsSVGPreserveAspectRatio.cpp.

{
  *result = (nsIDOMSVGPreserveAspectRatio*) new nsSVGPreserveAspectRatio(aAlign, aMeetOrSlice);
  if (!*result) return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*result);
  return NS_OK;
}
friend class nsSVGValueAutoNotifier [friend, inherited]

Definition at line 59 of file nsSVGValue.h.


Member Data Documentation

attribute unsigned short nsIDOMSVGPreserveAspectRatio::align [inherited]

Definition at line 61 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 71 of file nsSVGPreserveAspectRatio.cpp.

Definition at line 63 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 71 of file nsSVGPreserveAspectRatio.cpp.

Definition at line 58 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 59 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 57 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 46 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 45 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 55 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 52 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 49 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 54 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 51 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 48 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 53 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 50 of file nsIDOMSVGPresAspectRatio.idl.

Definition at line 47 of file nsIDOMSVGPresAspectRatio.idl.


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