nsIFrame* target; if (aReflowState.reflowCommand) { aReflowState.reflowCommand->GetTarget(target); if (target != this) { nsIFrame* nextFrame;  aReflowState.reflowCommand->GetNext(nextFrame);  if (nextFrame != nsnull) {
if (aReflowState.reason == eReflowReason_Incremental) { nsReflowPath::iterator iter = aReflowState.path->FirstChild(); nsReflowPath::iterator end = aReflowState.path->EndChildren();  for ( ; iter != end; ++iter) {
nsSVGOuterSVGFrame::Reflow(nsIPresContext*          aPresContext,                           nsHTMLReflowMetrics&     aDesiredSize,                           const nsHTMLReflowState& aReflowState,                           nsReflowStatus&          aStatus){  // check whether this reflow request is targeted at us or a child  // frame (e.g. a foreignObject):  nsIFrame* target;  if (aReflowState.reflowCommand) {    aReflowState.reflowCommand->GetTarget(target);    if (target != this) {      nsIFrame* nextFrame;      // Get the next frame in the reflow chain      aReflowState.reflowCommand->GetNext(nextFrame);            if (nextFrame != nsnull)      {        // The actual target of this reflow is one of our child        // frames. Since SVG as such doesn't use reflow, this will        // probably be the child of a <foreignObject>. Some HTML|XUL        // content frames target reflow events at themselves when they        // need to be redrawn in response to e.g. a style change. For        // correct visual updating, we must make sure the reflow        // reaches its intended target.                // Since it is an svg frame (probably an nsSVGForeignObjectFrame),        // we might as well pass in our aDesiredSize and aReflowState        // objects - they are ignored by svg frames:        nextFrame->Reflow (aPresContext,                           aDesiredSize,                           aReflowState,                           aStatus);        // XXX do we really have to return our metrics although we're        // not affected by the reflow? Is there a way of telling our        // parent that we don't want anything changed?        aDesiredSize.width  = mRect.width;        aDesiredSize.height = mRect.height;        aDesiredSize.ascent = aDesiredSize.height;        aDesiredSize.descent = 0;              aStatus = NS_FRAME_COMPLETE;        return NS_OK;      }    }  }    //  SVG CR 20001102: When the SVG content is embedded inline within  //  a containing document, and that document is styled using CSS,  //  then if there are CSS positioning properties specified on the  //  outermost 'svg' element that are sufficient to establish the  //  width of the viewport, then these positioning properties  //  establish the viewport's width; otherwise, the width attribute  //  on the outermost 'svg' element establishes the viewport's width.  //  Similarly, if there are CSS positioning properties specified on  //  the outermost 'svg' element that are sufficient to establish the  //  height of the viewport, then these positioning properties  //  establish the viewport's height; otherwise, the height attribute  //  on the outermost 'svg' element establishes the viewport's  //  height.#ifdef DEBUG  // printf("--- nsSVGOuterSVGFrame(%p)::Reflow(frame:%p,reason:%d) ---\n",this,aReflowState.frame,aReflowState.reason);#endif    NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);  nsCOMPtr<nsIDOMSVGSVGElement> SVGElement = do_QueryInterface(mContent);  NS_ENSURE_TRUE(SVGElement, NS_ERROR_FAILURE);  float pxPerTwips = GetPxPerTwips();  float twipsPerPx = GetTwipsPerPx();    // Temporarily set the viewport to the available size in  // case percentage width/height attribs have been given:  nsCOMPtr<nsIDOMSVGRect> viewport;  SVGElement->GetViewport(getter_AddRefs(viewport));  NS_ENSURE_TRUE(viewport, NS_ERROR_FAILURE);  NS_ENSURE_TRUE(aReflowState.parentReflowState, NS_ERROR_FAILURE);  viewport->SetWidth(aReflowState.parentReflowState->mComputedWidth * pxPerTwips);  if (aReflowState.parentReflowState->mComputedHeight != NS_UNCONSTRAINEDSIZE)    viewport->SetHeight(aReflowState.parentReflowState->mComputedHeight * pxPerTwips);  else    viewport->SetHeight(aReflowState.parentReflowState->mComputedWidth * pxPerTwips);#ifdef DEBUG  // some debug stuff://   {//     nsRect r;//     aPresContext->GetVisibleArea(r);//     printf("******* aw: %d, ah: %d visiw: %d, visih: %d\n",//            aReflowState.availableWidth,//            aReflowState.availableHeight,//            r.width, r.height);//     printf("******* cw: %d, ch: %d \n    cmaxw: %d, cmaxh: %d\n",//            aReflowState.mComputedWidth,//            aReflowState.mComputedHeight,//            aReflowState.mComputedMaxWidth,//            aReflowState.mComputedMaxHeight);//     if (aReflowState.parentReflowState) {//       printf("******* parent aw: %d, parent ah: %d \n",//              aReflowState.parentReflowState->availableWidth,//              aReflowState.parentReflowState->availableHeight);//       printf("******* parent cw: %d, parent ch: %d \n  parent cmaxw: %d, parent cmaxh: %d\n",//              aReflowState.parentReflowState->mComputedWidth,//              aReflowState.parentReflowState->mComputedHeight,//              aReflowState.parentReflowState->mComputedMaxWidth,//              aReflowState.parentReflowState->mComputedMaxHeight);//     }//   }#endif    // calculate width://  if (aReflowState.mComputedWidth == NS_INTRINSICSIZE)  {    nsCOMPtr<nsIDOMSVGAnimatedLength> animLength;    SVGElement->GetWidth(getter_AddRefs(animLength));    NS_ENSURE_TRUE(animLength, NS_ERROR_FAILURE);    nsCOMPtr<nsIDOMSVGLength> length;    animLength->GetAnimVal(getter_AddRefs(length));    NS_ENSURE_TRUE(length, NS_ERROR_FAILURE);        float w;    length->GetValue(&w);#ifdef DEBUG//    printf("  *intrinsic width:%f*\n",(double)w);#endif    aDesiredSize.width = (int) (twipsPerPx * w);  }//  else {//    aDesiredSize.width = aReflowState.mComputedWidth;//  }  // calculate height://  if (aReflowState.mComputedHeight == NS_INTRINSICSIZE)  {    nsCOMPtr<nsIDOMSVGAnimatedLength> animLength;    SVGElement->GetHeight(getter_AddRefs(animLength));    NS_ENSURE_TRUE(animLength, NS_ERROR_FAILURE);    nsCOMPtr<nsIDOMSVGLength> length;    animLength->GetAnimVal(getter_AddRefs(length));    NS_ENSURE_TRUE(length, NS_ERROR_FAILURE);    float h;    length->GetValue(&h);#ifdef DEBUG//    printf("  *intrinsic height:%f*\n",(double)h);#endif    aDesiredSize.height = (int) (twipsPerPx * h);  }//  else {//    aDesiredSize.height = aReflowState.mComputedHeight;//  }    aDesiredSize.ascent = aDesiredSize.height;  aDesiredSize.descent = 0;    // XXX add in CSS borders ??  aStatus = NS_FRAME_COMPLETE;  return NS_OK;}