Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
nsSVGTextFrame.cpp File Reference
#include "nsContainerFrame.h"
#include "nsIDOMSVGTextElement.h"
#include "nsPresContext.h"
#include "nsISVGTextFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsWeakReference.h"
#include "nsISVGValue.h"
#include "nsISVGValueObserver.h"
#include "nsIDOMSVGTransformable.h"
#include "nsIDOMSVGAnimTransformList.h"
#include "nsIDOMSVGSVGElement.h"
#include "nsIDOMSVGMatrix.h"
#include "nsIDOMSVGLengthList.h"
#include "nsIDOMSVGLength.h"
#include "nsISVGValueUtils.h"
#include "nsIDOMSVGAnimatedLengthList.h"
#include "nsIDOMSVGTransformList.h"
#include "nsISVGContainerFrame.h"
#include "nsISVGChildFrame.h"
#include "nsISVGGlyphFragmentNode.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsISVGRendererGlyphMetrics.h"
#include "nsISVGOuterSVGFrame.h"
#include "nsIDOMSVGRect.h"
#include "nsISVGTextContentMetrics.h"
#include "nsSVGRect.h"
#include "nsSVGMatrix.h"
#include "nsLayoutAtoms.h"
#include "nsISVGPathFlatten.h"
#include "nsSVGUtils.h"

Go to the source code of this file.

Classes

class  nsSVGTextFrame

Typedefs

typedef nsContainerFrame nsSVGTextFrameBase

Functions

nsresult NS_NewSVGTextFrame (nsIPresShell *aPresShell, nsIContent *aContent, nsIFrame **aNewFrame)
static void GetSingleValue (nsISVGGlyphFragmentLeaf *fragment, nsIDOMSVGLengthList *list, float *val)

Typedef Documentation

Definition at line 70 of file nsSVGTextFrame.cpp.


Function Documentation

static void GetSingleValue ( nsISVGGlyphFragmentLeaf fragment,
nsIDOMSVGLengthList list,
float *  val 
) [static]

Definition at line 976 of file nsSVGTextFrame.cpp.

{
  if (!list)
    return;

  PRUint32 count = 0;
  list->GetNumberOfItems(&count);
#ifdef DEBUG
  if (count > 1)
    NS_WARNING("multiple lengths for x/y attributes on <text> elements not implemented yet!");
#endif
  if (count) {
    nsCOMPtr<nsIDOMSVGLength> length;
    list->GetItem(0, getter_AddRefs(length));
    length->GetValue(val);

    /* check for % sizing of textpath */
    PRUint16 type;
    length->GetUnitType(&type);
    if (type == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) {
      nsIFrame *glyph;
      CallQueryInterface(fragment, &glyph);

      nsISVGPathFlatten *textPath = nsnull;
      /* check if we're the child of a textPath */
      for (nsIFrame *frame = glyph; frame != nsnull; frame = frame->GetParent())
        if (frame->GetType() == nsLayoutAtoms::svgTextPathFrame) {
          frame->QueryInterface(NS_GET_IID(nsISVGPathFlatten), 
                                (void **)&textPath);
          break;
        }

      if (textPath) {
        nsSVGPathData *data;
        textPath->GetFlattenedPath(&data);

        if (!data)
          return;

        float percent;
        length->GetValueInSpecifiedUnits(&percent);

        *val = data->Length()*percent/100.0f;
        delete data;
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewSVGTextFrame ( nsIPresShell aPresShell,
nsIContent aContent,
nsIFrame **  aNewFrame 
)

Definition at line 206 of file nsSVGTextFrame.cpp.

{
  *aNewFrame = nsnull;

  nsCOMPtr<nsIDOMSVGTextElement> text_elem = do_QueryInterface(aContent);
  if (!text_elem) {
#ifdef DEBUG
    printf("warning: trying to construct an SVGTextFrame for a "
           "content element that doesn't support the right interfaces\n");
#endif
    return NS_ERROR_FAILURE;
  }
  
  nsSVGTextFrame* it = new (aPresShell) nsSVGTextFrame;
  if (nsnull == it)
    return NS_ERROR_OUT_OF_MEMORY;

  *aNewFrame = it;
  
  return NS_OK;
}

Here is the call graph for this function: