Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
nsSVGGlyphFrame.cpp File Reference
#include "nsFrame.h"
#include "nsISVGRendererGlyphGeometry.h"
#include "nsISVGRendererGlyphMetrics.h"
#include "nsISVGRenderer.h"
#include "nsISVGGlyphGeometrySource.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsITextContent.h"
#include "nsISVGChildFrame.h"
#include "nsISVGOuterSVGFrame.h"
#include "nsISVGTextFrame.h"
#include "nsISVGRendererRegion.h"
#include "nsISVGContainerFrame.h"
#include "nsISVGTextContainerFrame.h"
#include "nsSVGGradient.h"
#include "nsISVGValueUtils.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "prdtoa.h"
#include "nsIDOMSVGRect.h"
#include "nsILookAndFeel.h"
#include "nsTextFragment.h"
#include "nsSVGRect.h"
#include "nsSVGPoint.h"
#include "nsSVGAtoms.h"
#include "nsIViewManager.h"
#include "nsINameSpaceManager.h"
#include "nsContainerFrame.h"
#include "nsLayoutAtoms.h"
#include "nsSVGUtils.h"
#include "nsISVGPathFlatten.h"

Go to the source code of this file.

Classes

class  nsSVGGlyphFrame

Typedefs

typedef nsFrame nsSVGGlyphFrameBase

Functions

nsresult NS_NewSVGGlyphFrame (nsIPresShell *aPresShell, nsIContent *aContent, nsIFrame *parentFrame, nsIFrame **aNewFrame)
void NS_SVGFindPointOnPath (nsSVGPathData *data, float aX, float aY, float aAdvance, nsSVGCharacterPosition *aCP)
int CompressIndex (int index, const nsTextFragment *fragment)
int UncompressIndex (int index, PRBool bRightAffinity, const nsTextFragment *fragment)

Typedef Documentation

Definition at line 70 of file nsSVGGlyphFrame.cpp.


Function Documentation

int CompressIndex ( int  index,
const nsTextFragment fragment 
)

Definition at line 1018 of file nsSVGGlyphFrame.cpp.

{
  int ci=0;
  if (fragment->Is2b()) {
    const PRUnichar *data=fragment->Get2b();
    while(*data && index) {
      if (XP_IS_SPACE_W(*data)){
        do {
          ++data;
          --index;
        }while(XP_IS_SPACE_W(*data) && index);
      }
      else {
        ++data;
        --index;
      }
      ++ci;
    }
  }
  else {
    const char *data=fragment->Get1b();
    while(*data && index) {
      if (XP_IS_SPACE_W(*data)){
        do {
          ++data;
          --index;
        }while(XP_IS_SPACE_W(*data) && index);
      }
      else {
        ++data;
        --index;
      }
      ++ci;
    }
  }
    
  return ci;
}

Here is the call graph for this function:

nsresult NS_NewSVGGlyphFrame ( nsIPresShell aPresShell,
nsIContent aContent,
nsIFrame parentFrame,
nsIFrame **  aNewFrame 
)

Definition at line 204 of file nsSVGGlyphFrame.cpp.

{
  *aNewFrame = nsnull;

#ifdef DEBUG
  NS_ASSERTION(parentFrame, "null parent");
  nsISVGTextContainerFrame *text_container;
  parentFrame->QueryInterface(NS_GET_IID(nsISVGTextContainerFrame), (void**)&text_container);
  NS_ASSERTION(text_container, "trying to construct an SVGGlyphFrame for an invalid container");
  
  nsCOMPtr<nsITextContent> tc = do_QueryInterface(aContent);
  NS_ASSERTION(tc, "trying to construct an SVGGlyphFrame for wrong content element");
#endif
  
  nsSVGGlyphFrame* it = new (aPresShell) nsSVGGlyphFrame;
  if (nsnull == it)
    return NS_ERROR_OUT_OF_MEMORY;

  *aNewFrame = it;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void NS_SVGFindPointOnPath ( nsSVGPathData data,
float  aX,
float  aY,
float  aAdvance,
nsSVGCharacterPosition aCP 
)

Definition at line 875 of file nsSVGGlyphFrame.cpp.

{
  float x, y, length = 0;
  float midpoint = aX + aAdvance/2;
  for (PRUint32 i = 0; i < data->count; i++) {
    if (data->type[i] == NS_SVGPATHFLATTEN_LINE) {
      float dx = data->x[i] - x;
      float dy = data->y[i] - y;
      float sublength = sqrt(dx*dx + dy*dy);
      
      if (sublength != 0 && length + sublength >= midpoint) {
        float ratio = (aX - length)/sublength;
        aCP->x = x * (1.0f - ratio) + data->x[i] * ratio;
        aCP->y = y * (1.0f - ratio) + data->y[i] * ratio;

        float dx = data->x[i] - x;
        float dy = data->y[i] - y;
        aCP->angle = atan2(dy, dx);

        float normalization = 1.0/sqrt(dx*dx+dy*dy);
        aCP->x += - aY * dy * normalization;
        aCP->y +=   aY * dx * normalization;
        return;
      }
      length += sublength;
    }
    x = data->x[i];
    y = data->y[i];
  }
}

Here is the call graph for this function:

int UncompressIndex ( int  index,
PRBool  bRightAffinity,
const nsTextFragment fragment 
)

Definition at line 1057 of file nsSVGGlyphFrame.cpp.

{
  // XXX
  return index;
}