Esempio n. 1
0
// Get the available reflow space for the current y coordinate. The
// available space is relative to our coordinate system (0,0) is our
// upper left corner.
nsresult
nsBlockBandData::GetAvailableSpace(nscoord aY, PRBool aRelaxHeightConstraint,
                                   nsRect& aResult)
{
  // Get the raw band data for the given Y coordinate
  nsresult rv = GetBandData(aY, aRelaxHeightConstraint);
  if (NS_FAILED(rv)) { return rv; }

  // Compute the bounding rect of the available space, i.e. space
  // between any left and right floats.
  ComputeAvailSpaceRect();
  aResult = mAvailSpace;
#ifdef REALLY_NOISY_COMPUTEAVAILSPACERECT
  printf("nsBBD %p GetAvailableSpace(%d) returing (%d, %d, %d, %d)\n",
          this, aY, aResult.x, aResult.y, aResult.width, aResult.height);
#endif
  return NS_OK;
}
Esempio n. 2
0
// Test of getting the band data
PRBool MySpaceManager::TestGetBandData()
{
  nsresult  status;
  nscoord   yMost;

  // Clear any existing regions
  ClearRegions();
  NS_ASSERTION(mBandList.IsEmpty(), "clear regions failed");

  // Make sure YMost() returns the correct result
  if (NS_ERROR_ABORT != YMost(yMost)) {
    printf("TestGetBandData: YMost() returned wrong result (#1)\n");
    return PR_FALSE;
  }

  // Make a band with three rects
  status = AddRectRegion((nsIFrame*)0x01, nsRect(100, 100, 100, 100));
  NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");

  status = AddRectRegion((nsIFrame*)0x02, nsRect(300, 100, 100, 100));
  NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");

  status = AddRectRegion((nsIFrame*)0x03, nsRect(500, 100, 100, 100));
  NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");

  // Verify that YMost() is correct
  if ((NS_OK != YMost(yMost)) || (yMost != 200)) {
    printf("TestGetBandData: YMost() returned wrong value (#2)\n");
    return PR_FALSE;
  }

  // Get the band data using a very large clip rect and a band data struct
  // that's large enough
  nsBandData      bandData;
  nsBandTrapezoid trapezoids[16];
  bandData.mSize = 16;
  bandData.mTrapezoids = trapezoids;
  status = GetBandData(100, nsSize(10000,10000), bandData);
  NS_ASSERTION(NS_SUCCEEDED(status), "unexpected status");

  // Verify that there are seven trapezoids
  if (bandData.mCount != 7) {
    printf("TestGetBandData: wrong trapezoid count (#3)\n");
    return PR_FALSE;
  }
  
  // Get the band data using a very large clip rect and a band data struct
  // that's too small
  bandData.mSize = 3;
  status = GetBandData(100, nsSize(10000,10000), bandData);
  if (NS_SUCCEEDED(status)) {
    printf("TestGetBandData: ignored band data count (#4)\n");
    return PR_FALSE;
  }

  // Make sure the count has been updated to reflect the number of trapezoids
  // required
  if (bandData.mCount <= bandData.mSize) {
    printf("TestGetBandData: bad band data count (#5)\n");
    return PR_FALSE;
  }

  // XXX We need lots more tests here...

  return PR_TRUE;
}