nsIFrame* prevInFlow; pfd->mFrame->GetPrevInFlow(&prevInFlow);
nsIFrame* prevInFlow = pfd->mFrame->GetPrevInFlow();
nsLineLayout::CanPlaceFrame(PerFrameData* pfd,                            const nsHTMLReflowState& aReflowState,                            PRBool aNotSafeToBreak,                            nsHTMLReflowMetrics& aMetrics,                            nsReflowStatus& aStatus){  NS_PRECONDITION(pfd && pfd->mFrame, "bad args, null pointers for frame data");  // Compute right margin to use  if (0 != pfd->mBounds.width) {    NS_ASSERTION(aReflowState.mStyleDisplay->mFloats == NS_STYLE_FLOAT_NONE,                 "How'd we get a floated inline frame? "                 "The frame ctor should've dealt with this.");    // XXXwaterson this is probably not exactly right; e.g., embeddings, etc.    PRBool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection);    if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {      // Only apply end margin for the last-in-flow. Zero this out so      // that when we compute the max-element-width of the frame we      // will properly avoid adding in the end margin.      if (ltr)        pfd->mMargin.right = 0;      else        pfd->mMargin.left = 0;    }  }  else {    // Don't apply margin to empty frames.    pfd->mMargin.left = pfd->mMargin.right = 0;  }  PerSpanData* psd = mCurrentSpan;  if (psd->mNoWrap) {    // When wrapping is off, everything fits.    return PR_TRUE;  }#ifdef NOISY_CAN_PLACE_FRAME  if (nsnull != psd->mFrame) {    nsFrame::ListTag(stdout, psd->mFrame->mFrame);  }  else {    nsFrame::ListTag(stdout, mBlockReflowState->frame);  }   printf(": aNotSafeToBreak=%s frame=", aNotSafeToBreak ? "true" : "false");  nsFrame::ListTag(stdout, pfd->mFrame);  printf(" frameWidth=%d\n", pfd->mBounds.XMost() + rightMargin - psd->mX);#endif  // Set outside to PR_TRUE if the result of the reflow leads to the  // frame sticking outside of our available area.  PRBool outside = pfd->mBounds.XMost() + pfd->mMargin.right > psd->mRightEdge;  if (!outside) {    // If it fits, it fits#ifdef NOISY_CAN_PLACE_FRAME    printf("   ==> inside\n");#endif    return PR_TRUE;  }  // When it doesn't fit, check for a few special conditions where we  // allow it to fit anyway.  if (0 == pfd->mMargin.left + pfd->mBounds.width + pfd->mMargin.right) {    // Empty frames always fit right where they are#ifdef NOISY_CAN_PLACE_FRAME    printf("   ==> empty frame fits\n");#endif    return PR_TRUE;  }#ifdef FIX_BUG_50257  // another special case:  always place a BR  if (nsLayoutAtoms::brFrame == pfd->mFrame->GetType()) {#ifdef NOISY_CAN_PLACE_FRAME    printf("   ==> BR frame fits\n");#endif    return PR_TRUE;  }#endif  if (aNotSafeToBreak) {    // There are no frames on the line or we are in the first word on    // the line. If the line isn't impacted by a float then the    // current frame fits.    if (!GetFlag(LL_IMPACTEDBYFLOATS)) {#ifdef NOISY_CAN_PLACE_FRAME      printf("   ==> not-safe and not-impacted fits: ");      while (nsnull != psd) {        printf("<psd=%p x=%d left=%d> ", psd, psd->mX, psd->mLeftEdge);        psd = psd->mParent;      }      printf("\n");#endif      return PR_TRUE;    }    else if (GetFlag(LL_LASTFLOATWASLETTERFRAME)) {      // Another special case: see if the float is a letter      // frame. If it is, then allow the frame next to it to fit.      if (pfd->GetFlag(PFD_ISNONEMPTYTEXTFRAME)) {        // This must be the first piece of non-empty text (because        // aNotSafeToBreak is true) or its a piece of text that is        // part of a larger word.        pfd->SetFlag(PFD_ISSTICKY, PR_TRUE);      }      else if (pfd->mSpan) {        PerFrameData* pf = pfd->mSpan->mFirstFrame;        while (pf) {          if (pf->GetFlag(PFD_ISSTICKY)) {            // If one of the spans children was sticky then the span            // itself is sticky.            pfd->SetFlag(PFD_ISSTICKY, PR_TRUE);          }          pf = pf->mNext;        }      }      if (pfd->GetFlag(PFD_ISSTICKY)) {#ifdef NOISY_CAN_PLACE_FRAME        printf("   ==> last float was letter frame && frame is sticky\n");#endif        return PR_TRUE;      }    }  }  // If this is a piece of text inside a letter frame...  if (pfd->GetFlag(PFD_ISNONEMPTYTEXTFRAME)) {    if (psd->mFrame && psd->mFrame->GetFlag(PFD_ISLETTERFRAME)) {      nsIFrame* prevInFlow;      psd->mFrame->mFrame->GetPrevInFlow(&prevInFlow);      if (prevInFlow) {        nsIFrame* prevPrevInFlow;        prevInFlow->GetPrevInFlow(&prevPrevInFlow);        if (!prevPrevInFlow) {          // And it's the first continuation of the letter frame...          // Then make sure that the text fits          return PR_TRUE;        }      }    }  }  else if (pfd->GetFlag(PFD_ISLETTERFRAME)) {    // If this is the first continuation of the letter frame...    nsIFrame* prevInFlow;    pfd->mFrame->GetPrevInFlow(&prevInFlow);    if (prevInFlow) {      nsIFrame* prevPrevInFlow;      prevInFlow->GetPrevInFlow(&prevPrevInFlow);      if (!prevPrevInFlow) {        return PR_TRUE;      }    }  }  // Special check for span frames  if (pfd->mSpan && pfd->mSpan->mContainsFloat) {    // If the span either directly or indirectly contains a float then    // it fits. Why? It's kind of complicated, but here goes:    //    // 1. CanPlaceFrame is used for all frame placements on a line,    // and in a span. This includes recursively placement of frames    // inside of spans, and the span itself. Because the logic always    // checks for room before proceeding (the code above here), the    // only things on a line will be those things that "fit".    //    // 2. Before a float is placed on a line, the line has to be empty    // (otherwise its a "below current line" flaoter and will be placed    // after the line).    //    // Therefore, if the span directly or indirectly has a float    // then it means that at the time of the placement of the float    // the line was empty. Because of #1, only the frames that fit can    // be added after that point, therefore we can assume that the    // current span being placed has fit.    //    // So how do we get here and have a span that should already fit    // and yet doesn't: Simple: span's that have the no-wrap attribute    // set on them and contain a float and are placed where they    // don't naturally fit.    return PR_TRUE; }#ifdef NOISY_CAN_PLACE_FRAME  printf("   ==> didn't fit\n");#endif  aStatus = NS_INLINE_LINE_BREAK_BEFORE();  return PR_FALSE;}