NS_ASSERTION(metrics, "null metrics");
if (!metrics) continue;
nsSVGTextFrame::UpdateGlyphPositioning(){  // XXX need to iterate separately over each chunk (currently we  // treat everything underneath this text-element as a single chunk)    NS_ASSERTION(mMetricsState == unsuspended, "updating during suspension");  nsISVGGlyphFragmentNode *node = GetFirstGlyphFragmentChildNode();  if (!node) return;  nsISVGGlyphFragmentLeaf* fragment;  float x=0.0f;  {    nsCOMPtr<nsIDOMSVGLengthList> list = GetX();    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(&x);    }  }    float y=0.0f;  {    nsCOMPtr<nsIDOMSVGLengthList> list = GetY();    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(&y);    }  }  // determine x offset based on text_anchor:    PRUint8 anchor = GetStyleSVG()->mTextAnchor;  float chunkLength = 0.0f;  if (anchor != NS_STYLE_TEXT_ANCHOR_START) {    // need to get the total chunk length        fragment = node->GetFirstGlyphFragment();    while (fragment) {      nsCOMPtr<nsISVGRendererGlyphMetrics> metrics;      fragment->GetGlyphMetrics(getter_AddRefs(metrics));      NS_ASSERTION(metrics, "null metrics");      float advance;      metrics->GetAdvance(&advance);      chunkLength+=advance;      fragment = fragment->GetNextGlyphFragment();    }  }  if (anchor == NS_STYLE_TEXT_ANCHOR_MIDDLE)     x -= chunkLength/2.0f;  else if (anchor == NS_STYLE_TEXT_ANCHOR_END)    x -= chunkLength;  // we'll align every fragment in this chunk on the dominant-baseline:  // XXX should actually inspect 'alignment-baseline' for each fragment    PRUint8 baseline;  switch(GetStyleSVGReset()->mDominantBaseline) {    case NS_STYLE_DOMINANT_BASELINE_TEXT_BEFORE_EDGE:      baseline = nsISVGRendererGlyphMetrics::BASELINE_TEXT_BEFORE_EDGE;      break;    case NS_STYLE_DOMINANT_BASELINE_TEXT_AFTER_EDGE:      baseline = nsISVGRendererGlyphMetrics::BASELINE_TEXT_AFTER_EDGE;      break;    case NS_STYLE_DOMINANT_BASELINE_MIDDLE:      baseline = nsISVGRendererGlyphMetrics::BASELINE_MIDDLE;      break;    case NS_STYLE_DOMINANT_BASELINE_CENTRAL:      baseline = nsISVGRendererGlyphMetrics::BASELINE_CENTRAL;      break;    case NS_STYLE_DOMINANT_BASELINE_MATHEMATICAL:      baseline = nsISVGRendererGlyphMetrics::BASELINE_MATHEMATICAL;      break;    case NS_STYLE_DOMINANT_BASELINE_IDEOGRAPHIC:      baseline = nsISVGRendererGlyphMetrics::BASELINE_IDEOGRAPHC;      break;    case NS_STYLE_DOMINANT_BASELINE_HANGING:      baseline = nsISVGRendererGlyphMetrics::BASELINE_HANGING;      break;    case NS_STYLE_DOMINANT_BASELINE_AUTO:    case NS_STYLE_DOMINANT_BASELINE_USE_SCRIPT:    case NS_STYLE_DOMINANT_BASELINE_ALPHABETIC:    default:      baseline = nsISVGRendererGlyphMetrics::BASELINE_ALPHABETIC;      break;  }    // set position of each fragment in this chunk:    fragment = node->GetFirstGlyphFragment();  while (fragment) {    nsCOMPtr<nsISVGRendererGlyphMetrics> metrics;    fragment->GetGlyphMetrics(getter_AddRefs(metrics));    NS_ASSERTION(metrics, "null metrics");    float baseline_offset;    metrics->GetBaselineOffset(baseline, &baseline_offset);    fragment->SetGlyphPosition(x, y - baseline_offset);    float advance;    metrics->GetAdvance(&advance);    x+=advance;    fragment = fragment->GetNextGlyphFragment();  }  mPositioningDirty = PR_FALSE;}