region.y = mY - mBorderPadding.top;
nsBlockReflowState::PlaceFloater(nsPlaceholderFrame* aPlaceholder,                                 PRBool& aIsLeftFloater){  nsIFrame* floater = aPlaceholder->GetAnchoredItem();  // Reflow the floater if it's targetted for a reflow  if (nsnull != reflowCommand) {    nsIFrame* target;    reflowCommand->GetTarget(target);    if (floater == target) {      mBlock->ReflowFloater(mPresContext, *this, floater);    }  }  // Get the type of floater  const nsStyleDisplay* floaterDisplay;  const nsStyleSpacing* floaterSpacing;  floater->GetStyleData(eStyleStruct_Display,                        (const nsStyleStruct*&)floaterDisplay);  floater->GetStyleData(eStyleStruct_Spacing,                        (const nsStyleStruct*&)floaterSpacing);  // See if the floater should clear any preceeding floaters...  if (NS_STYLE_CLEAR_NONE != floaterDisplay->mBreakType) {    ClearFloaters(floaterDisplay->mBreakType);  }  else {    // Get the band of available space    GetAvailableSpace();  }  // Get the floaters bounding box and margin information  nsRect region;  floater->GetRect(region);  nsMargin floaterMargin;  floaterSpacing->CalcMarginFor(floater, floaterMargin);  // Adjust the floater size by its margin. That's the area that will  // impact the space manager.  region.width += floaterMargin.left + floaterMargin.right;  region.height += floaterMargin.top + floaterMargin.bottom;  // Find a place to place the floater. The CSS2 spec doesn't want  // floaters overlapping each other or sticking out of the containing  // block (CSS2 spec section 9.5.1, see the rule list).  NS_ASSERTION((NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) ||               (NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats),               "invalid float type");  // While there is not enough room for the floater, clear past  // other floaters until there is room (or the band is not impacted  // by a floater).  while ((mCurrentBand.availSpace.width < region.width) &&         (mCurrentBand.availSpace.width < mContentArea.width)) {    // The CSS2 spec says that floaters should be placed as high as    // possible. We accomodate this easily by noting that if the band    // is not the full width of the content area then it must have    // been impacted by a floater. And we know that the height of the    // band will be the height of the shortest floater, therefore we    // adjust mY by that distance and keep trying until we have enough    // space for this floater.    mY += mCurrentBand.availSpace.height;    GetAvailableSpace();  }  // Assign an x and y coordinate to the floater. Note that the x,y  // coordinates are computed <b>relative to the translation in the  // spacemanager</b> which means that the impacted region will be  // <b>inside</b> the border/padding area.  if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {    aIsLeftFloater = PR_TRUE;    region.x = mCurrentBand.availSpace.x;  }  else {    aIsLeftFloater = PR_FALSE;    region.x = mCurrentBand.availSpace.XMost() - region.width;  }  region.y = mY - mBorderPadding.top;  if (region.y < 0) {    // CSS2 spec, 9.5.1 rule [4]: A floating box's outer top may not    // be higher than the top of its containing block.    // XXX It's not clear if it means the higher than the outer edge    // or the border edge or the inner edge?    region.y = 0;  }  // Place the floater in the space manager  mSpaceManager->AddRectRegion(floater, region);  // Set the origin of the floater frame, in frame coordinates. These  // coordinates are <b>not</b> relative to the spacemanager  // translation, therefore we have to factor in our border/padding.  floater->MoveTo(mBorderPadding.left + floaterMargin.left + region.x,                  mBorderPadding.top + floaterMargin.top + region.y);}