Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsBlockReflowContext.cpp File Reference
#include "nsBlockReflowContext.h"
#include "nsLineLayout.h"
#include "nsSpaceManager.h"
#include "nsIFontMetrics.h"
#include "nsPresContext.h"
#include "nsFrameManager.h"
#include "nsIContent.h"
#include "nsStyleContext.h"
#include "nsHTMLReflowCommand.h"
#include "nsHTMLContainerFrame.h"
#include "nsBlockFrame.h"
#include "nsLineBox.h"
#include "nsIDOMHTMLTableCellElement.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsLayoutAtoms.h"
#include "nsCOMPtr.h"
#include "nsLayoutUtils.h"

Go to the source code of this file.

Classes

struct  nsBlockHorizontalAlign

Functions

static nsIFrameDescendIntoBlockLevelFrame (nsIFrame *aFrame)
static void ComputeShrinkwrapMargins (const nsStyleMargin *aStyleMargin, nscoord aWidth, nsMargin &aMargin, nscoord &aXToUpdate)
static void nsPointDtor (void *aFrame, nsIAtom *aPropertyName, void *aPropertyValue, void *aDtorData)

Class Documentation

struct nsBlockHorizontalAlign

Definition at line 225 of file nsBlockReflowContext.cpp.

Class Members
nscoord mLeftMargin
nscoord mRightMargin
nscoord mXOffset

Function Documentation

static void ComputeShrinkwrapMargins ( const nsStyleMargin aStyleMargin,
nscoord  aWidth,
nsMargin aMargin,
nscoord aXToUpdate 
) [static]

Definition at line 325 of file nsBlockReflowContext.cpp.

{
  nscoord boxWidth = aWidth;
  float leftPct = 0.0, rightPct = 0.0;
  const nsStyleSides& margin = aStyleMargin->mMargin;
  
  if (eStyleUnit_Percent == margin.GetLeftUnit()) {
    nsStyleCoord coord;
    leftPct = margin.GetLeft(coord).GetPercentValue();
  } else {
    boxWidth += aMargin.left;
  }
  
  if (eStyleUnit_Percent == margin.GetRightUnit()) {
    nsStyleCoord coord;
    rightPct = margin.GetRight(coord).GetPercentValue();
  } else {
    boxWidth += aMargin.right;
  }
  
  // The total shrink wrap width "sww" (i.e., the width that the
  // containing block needs to be to shrink-wrap this block) is
  // calculated by the expression:
  //   sww = bw + (mp * sww)
  // where "bw" is the box width (frame width plus margins that aren't
  // percentage based) and "mp" are the total margin percentages (i.e.,
  // the left percentage value plus the right percentage value).
  // Solving for "sww" gives:
  //  sww = bw / (1 - mp)
  // Note that this is only well defined for "mp" less than 100% and 
  // greater than -100% (XXXldb but we only accept 0 to 100%).

  float marginPct = leftPct + rightPct;
  if (marginPct >= 1.0) {
    // Ignore the right percentage and just use the left percentage
    // XXX Pay attention to direction property...
    marginPct = leftPct;
    rightPct = 0.0;
  }
  
  if ((marginPct > 0.0) && (marginPct < 1.0)) {
    double shrinkWrapWidth = float(boxWidth) / (1.0 - marginPct);
    
    if (eStyleUnit_Percent == margin.GetLeftUnit()) {
      aMargin.left = NSToCoordFloor((float)(shrinkWrapWidth * leftPct));
      aXToUpdate += aMargin.left;
    }
    if (eStyleUnit_Percent == margin.GetRightUnit()) {
      aMargin.right = NSToCoordFloor((float)(shrinkWrapWidth * rightPct));
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIFrame* DescendIntoBlockLevelFrame ( nsIFrame aFrame) [static]

Definition at line 83 of file nsBlockReflowContext.cpp.

{
  nsIAtom* type = aFrame->GetType();
  if (type == nsLayoutAtoms::columnSetFrame)
    return DescendIntoBlockLevelFrame(aFrame->GetFirstChild(nsnull));
  return aFrame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsPointDtor ( void aFrame,
nsIAtom aPropertyName,
void aPropertyValue,
void aDtorData 
) [static]

Definition at line 380 of file nsBlockReflowContext.cpp.

{
  nsPoint *point = NS_STATIC_CAST(nsPoint*, aPropertyValue);
  delete point;
}

Here is the caller graph for this function: