region.x = mAvailSpaceRect.XMost() - region.width;
if (mUnconstrainedWidth) {          okToAddRectRegion = PR_FALSE; region.x = mAvailSpaceRect.x; } else { region.x = mAvailSpaceRect.XMost() - region.width; }
nsBlockReflowState::PlaceFloater(nsFloaterCache* aFloaterCache,                                 PRBool* aIsLeftFloater,                                 nsPoint* aNewOrigin){  // Save away the Y coordinate before placing the floater. We will  // restore mY at the end after placing the floater. This is  // necessary because any adjustments to mY during the floater  // placement are for the floater only, not for any non-floating  // content.  nscoord saveY = mY;  nsIFrame* floater = aFloaterCache->mPlaceholder->GetOutOfFlowFrame();  // Get the type of floater  const nsStyleDisplay* floaterDisplay;  const nsStyleSpacing* floaterSpacing;  const nsStylePosition* floaterPosition;  floater->GetStyleData(eStyleStruct_Display,                        (const nsStyleStruct*&)floaterDisplay);  floater->GetStyleData(eStyleStruct_Spacing,                        (const nsStyleStruct*&)floaterSpacing);  floater->GetStyleData(eStyleStruct_Position,                        (const nsStyleStruct*&)floaterPosition);  // See if the floater should clear any preceeding floaters...  if (NS_STYLE_CLEAR_NONE != floaterDisplay->mBreakType) {    ClearFloaters(mY, floaterDisplay->mBreakType);  }  else {    // Get the band of available space    GetAvailableSpace();  }  // Get the floaters bounding box and margin information  nsRect region;  floater->GetRect(region);  // Adjust the floater size by its margin. That's the area that will  // impact the space manager.  region.width += aFloaterCache->mMargins.left + aFloaterCache->mMargins.right;  region.height += aFloaterCache->mMargins.top + aFloaterCache->mMargins.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 if possible (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).  //   // Note: The CSS2 spec says that floaters should be placed as high  // as possible.  while (!CanPlaceFloater(region, floaterDisplay->mFloats)) {    mY += mAvailSpaceRect.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 = mAvailSpaceRect.x;  }  else {    *aIsLeftFloater = PR_FALSE;    region.x = mAvailSpaceRect.XMost() - region.width;  }  const nsMargin& borderPadding = BorderPadding();  region.y = mY - borderPadding.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);  // Save away the floaters region in the spacemanager, after making  // it relative to the containing block's frame instead of relative  // to the spacemanager translation (which is inset by the  // border+padding).  aFloaterCache->mRegion.x = region.x + borderPadding.left;  aFloaterCache->mRegion.y = region.y + borderPadding.top;  aFloaterCache->mRegion.width = region.width;  aFloaterCache->mRegion.height = region.height;#ifdef NOISY_SPACEMANAGER  nscoord tx, ty;  mSpaceManager->GetTranslation(tx, ty);  nsFrame::ListTag(stdout, mBlock);  printf(": PlaceFloater: AddRectRegion: txy=%d,%d (%d,%d) {%d,%d,%d,%d}\n",         tx, ty, mSpaceManagerX, mSpaceManagerY,         aFloaterCache->mRegion.x, aFloaterCache->mRegion.y,         aFloaterCache->mRegion.width, aFloaterCache->mRegion.height);#endif  // 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.  nscoord x = borderPadding.left + aFloaterCache->mMargins.left + region.x;  nscoord y = borderPadding.top + aFloaterCache->mMargins.top + region.y;  // If floater is relatively positioned, factor that in as well  if (NS_STYLE_POSITION_RELATIVE == floaterPosition->mPosition) {    x += aFloaterCache->mOffsets.left;    y += aFloaterCache->mOffsets.top;  }  floater->MoveTo(x, y);  if (aNewOrigin) {    aNewOrigin->x = x;    aNewOrigin->y = y;  }  // Now restore mY  mY = saveY;#ifdef NOISY_INCREMENTAL_REFLOW  if (mReflowState.reason == eReflowReason_Incremental) {    nsRect r;    floater->GetRect(r);    nsFrame::IndentBy(stdout, gNoiseIndent);    printf("placed floater: ");    ((nsFrame*)floater)->ListTag(stdout);    printf(" %d,%d,%d,%d\n", r.x, r.y, r.width, r.height);  }#endif}