Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions | Variables
nsCSSRendering.cpp File Reference
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsIImage.h"
#include "nsIFrame.h"
#include "nsPoint.h"
#include "nsRect.h"
#include "nsIViewManager.h"
#include "nsIPresShell.h"
#include "nsFrameManager.h"
#include "nsStyleContext.h"
#include "nsIScrollableView.h"
#include "nsLayoutAtoms.h"
#include "nsIDrawingSurface.h"
#include "nsTransform2D.h"
#include "nsIDeviceContext.h"
#include "nsIContent.h"
#include "nsHTMLAtoms.h"
#include "nsIDocument.h"
#include "nsIScrollableFrame.h"
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include "nsCSSRendering.h"
#include "nsCSSColorUtils.h"
#include "nsITheme.h"
#include "nsThemeConstants.h"
#include "nsIServiceManager.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLDocument.h"
#include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"

Go to the source code of this file.

Classes

struct  InlineBackgroundData

Defines

#define BORDER_FULL   0
#define BORDER_INSIDE   1
#define BORDER_OUTSIDE   2
#define DOT_LENGTH   1
#define DASH_LENGTH   3
#define MAXPATHSIZE   12
 The following classes are used by CSSRendering for the rounded rect implementation.
#define MAXPOLYPATHSIZE   1000
#define MAX_POLY_POINTS   4
#define ACTUAL_THICKNESS(outside, inside, frac, tpp)   (NSToCoordRound(((outside) - (inside)) * (frac) / (tpp)) * (tpp))
#define MOZ_BG_BORDER(a)

Enumerations

enum  ePathTypes { eOutside = 0, eInside, eCalc, eCalcRev }

Functions

static void GetPath (nsFloatPoint aPoints[], nsPoint aPolyPath[], PRInt32 *aCurIndex, ePathTypes aPathType, PRInt32 &aC1Index, float aFrac)
 
Given a qbezier path, convert it into a polygon path 3/26/99 dwc
static void FillOrInvertRect (nsIRenderingContext &aRC, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aInvert)
static void FillOrInvertRect (nsIRenderingContext &aRC, const nsRect &aRect, PRBool aInvert)
PRBool GetBGColorForHTMLElement (nsPresContext *aPresContext, const nsStyleBackground *&aBGColor)
static PRBool GetBorderColor (const nsStyleColor *aColor, const nsStyleBorder &aBorder, PRUint8 aSide, nscolor &aColorVal, nsBorderColors **aCompositeColors=nsnull)
static void ComputeBackgroundAnchorPoint (const nsStyleBackground &aColor, const nsRect &aOriginBounds, const nsRect &aClipBounds, nscoord aTileWidth, nscoord aTileHeight, nsPoint &aResult)
static nsIScrollableFrameGetRootScrollableFrame (nsPresContext *aPresContext, nsIFrame *aRootFrame)
nsIFrameIsCanvasFrame (nsPresContext *aPresContext, nsIFrame *aFrame)
 |FindBackground| finds the correct style data to use to paint the background.
PRBool FindCanvasBackground (nsPresContext *aPresContext, nsIFrame *aForFrame, const nsStyleBackground **aBackground)
PRBool FindElementBackground (nsPresContext *aPresContext, nsIFrame *aForFrame, const nsStyleBackground **aBackground)
static nscoord RoundIntToPixel (nscoord aValue, nscoord aTwipsPerPixel, PRBool aRoundDown=PR_FALSE)
static nscoord RoundFloatToPixel (float aValue, nscoord aTwipsPerPixel, PRBool aRoundDown=PR_FALSE)
static void SetPoly (const nsRect &aRect, nsPoint *poly)
static void DrawSolidBorderSegment (nsIRenderingContext &aContext, nsRect aRect, nscoord aTwipsPerPixel, PRUint8 aStartBevelSide=0, nscoord aStartBevelOffset=0, PRUint8 aEndBevelSide=0, nscoord aEndBevelOffset=0)
static void GetDashInfo (nscoord aBorderLength, nscoord aDashLength, nscoord aTwipsPerPixel, PRInt32 &aNumDashSpaces, nscoord &aStartDashLength, nscoord &aEndDashLength)

Variables

static InlineBackgroundData gInlineBGData

Define Documentation

#define ACTUAL_THICKNESS (   outside,
  inside,
  frac,
  tpp 
)    (NSToCoordRound(((outside) - (inside)) * (frac) / (tpp)) * (tpp))

Definition at line 345 of file nsCSSRendering.cpp.

Definition at line 72 of file nsCSSRendering.cpp.

Definition at line 73 of file nsCSSRendering.cpp.

Definition at line 74 of file nsCSSRendering.cpp.

Definition at line 78 of file nsCSSRendering.cpp.

#define DOT_LENGTH   1

Definition at line 77 of file nsCSSRendering.cpp.

Definition at line 343 of file nsCSSRendering.cpp.

#define MAXPATHSIZE   12

The following classes are used by CSSRendering for the rounded rect implementation.

Definition at line 82 of file nsCSSRendering.cpp.

#define MAXPOLYPATHSIZE   1000

Definition at line 83 of file nsCSSRendering.cpp.


Enumeration Type Documentation

enum ePathTypes
Enumerator:
eOutside 
eInside 
eCalc 
eCalcRev 

Definition at line 85 of file nsCSSRendering.cpp.


Function Documentation

static void ComputeBackgroundAnchorPoint ( const nsStyleBackground aColor,
const nsRect aOriginBounds,
const nsRect aClipBounds,
nscoord  aTileWidth,
nscoord  aTileHeight,
nsPoint aResult 
) [static]

Definition at line 2395 of file nsCSSRendering.cpp.

{
  nscoord x;
  if (NS_STYLE_BG_X_POSITION_LENGTH & aColor.mBackgroundFlags) {
    x = aColor.mBackgroundXPosition.mCoord;
  }
  else if (NS_STYLE_BG_X_POSITION_PERCENT & aColor.mBackgroundFlags) {
    PRFloat64 percent = PRFloat64(aColor.mBackgroundXPosition.mFloat);
    nscoord tilePos = nscoord(percent * PRFloat64(aTileWidth));
    nscoord boxPos = nscoord(percent * PRFloat64(aOriginBounds.width));
    x = boxPos - tilePos;
  }
  else {
    x = 0;
  }
  x += aOriginBounds.x - aClipBounds.x;
  if (NS_STYLE_BG_REPEAT_X & aColor.mBackgroundRepeat) {
    // When we are tiling in the x direction the loop will run from
    // the left edge of the box to the right edge of the box. We need
    // to adjust the starting coordinate to lie within the band being
    // rendered.
    if (x < 0) {
      x = -x;
      if (x < 0) {
        // Some joker gave us max-negative-integer.
        x = 0;
      }
      x %= aTileWidth;
      x = -x;
    }
    else if (x != 0) {
      x %= aTileWidth;
      if (x > 0) {
        x = x - aTileWidth;
      }
    }

    NS_POSTCONDITION((x >= -(aTileWidth - 1)) && (x <= 0), "bad computed anchor value");
  }
  aResult.x = x;

  nscoord y;
  if (NS_STYLE_BG_Y_POSITION_LENGTH & aColor.mBackgroundFlags) {
    y = aColor.mBackgroundYPosition.mCoord;
  }
  else if (NS_STYLE_BG_Y_POSITION_PERCENT & aColor.mBackgroundFlags){
    PRFloat64 percent = PRFloat64(aColor.mBackgroundYPosition.mFloat);
    nscoord tilePos = nscoord(percent * PRFloat64(aTileHeight));
    nscoord boxPos = nscoord(percent * PRFloat64(aOriginBounds.height));
    y = boxPos - tilePos;
  }
  else {
    y = 0;
  }
  y += aOriginBounds.y - aClipBounds.y;
  if (NS_STYLE_BG_REPEAT_Y & aColor.mBackgroundRepeat) {
    // When we are tiling in the y direction the loop will run from
    // the top edge of the box to the bottom edge of the box. We need
    // to adjust the starting coordinate to lie within the band being
    // rendered.
    if (y < 0) {
      y = -y;
      if (y < 0) {
        // Some joker gave us max-negative-integer.
        y = 0;
      }
      y %= aTileHeight;
      y = -y;
    }
    else if (y != 0) {
      y %= aTileHeight;
      if (y > 0) {
        y = y - aTileHeight;
      }
    }
    
    NS_POSTCONDITION((y >= -(aTileHeight - 1)) && (y <= 0), "bad computed anchor value");
  }
  aResult.y = y;
}

Here is the caller graph for this function:

static void DrawSolidBorderSegment ( nsIRenderingContext aContext,
nsRect  aRect,
nscoord  aTwipsPerPixel,
PRUint8  aStartBevelSide = 0,
nscoord  aStartBevelOffset = 0,
PRUint8  aEndBevelSide = 0,
nscoord  aEndBevelOffset = 0 
) [static]

Definition at line 4120 of file nsCSSRendering.cpp.

{

  if ((aRect.width == aTwipsPerPixel) || (aRect.height == aTwipsPerPixel) ||
      ((0 == aStartBevelOffset) && (0 == aEndBevelOffset))) {
    // simple line or rectangle
    if ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide)) {
      if (1 == aRect.height) 
        aContext.DrawLine(aRect.x, aRect.y, aRect.x, aRect.y + aRect.height); 
      else 
        aContext.FillRect(aRect);
    }
    else {
      if (1 == aRect.width) 
        aContext.DrawLine(aRect.x, aRect.y, aRect.x + aRect.width, aRect.y); 
      else 
        aContext.FillRect(aRect);
    }
  }
  else {
    // polygon with beveling
    nsPoint poly[5];
    SetPoly(aRect, poly);
    switch(aStartBevelSide) {
    case NS_SIDE_TOP:
      poly[0].x += aStartBevelOffset;
      poly[4].x = poly[0].x;
      break;
    case NS_SIDE_BOTTOM:
      poly[3].x += aStartBevelOffset;
      break;
    case NS_SIDE_RIGHT:
      poly[1].y += aStartBevelOffset;
      break;
    case NS_SIDE_LEFT:
      poly[0].y += aStartBevelOffset;
      poly[4].y = poly[0].y;
    }

    switch(aEndBevelSide) {
    case NS_SIDE_TOP:
      poly[1].x -= aEndBevelOffset;
      break;
    case NS_SIDE_BOTTOM:
      poly[2].x -= aEndBevelOffset;
      break;
    case NS_SIDE_RIGHT:
      poly[2].y -= aEndBevelOffset;
      break;
    case NS_SIDE_LEFT:
      poly[3].y -= aEndBevelOffset;
    }

    aContext.FillPolygon(poly, 5);
  }


}

Here is the call graph for this function:

Here is the caller graph for this function:

void FillOrInvertRect ( nsIRenderingContext aRC,
nscoord  aX,
nscoord  aY,
nscoord  aWidth,
nscoord  aHeight,
PRBool  aInvert 
) [static]

Definition at line 4057 of file nsCSSRendering.cpp.

{
  if (aInvert) {
    aRC.InvertRect(aX, aY, aWidth, aHeight);
  } else {
    aRC.FillRect(aX, aY, aWidth, aHeight);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FillOrInvertRect ( nsIRenderingContext aRC,
const nsRect aRect,
PRBool  aInvert 
) [static]

Definition at line 4066 of file nsCSSRendering.cpp.

{
  if (aInvert) {
    aRC.InvertRect(aRect);
  } else {
    aRC.FillRect(aRect);
  }
}

Here is the call graph for this function:

PRBool FindCanvasBackground ( nsPresContext aPresContext,
nsIFrame aForFrame,
const nsStyleBackground **  aBackground 
) [inline]

Definition at line 2593 of file nsCSSRendering.cpp.

{
  // XXXldb What if the root element is positioned, etc.?  (We don't
  // allow that yet, do we?)
  nsIFrame *firstChild = aForFrame->GetFirstChild(nsnull);
  if (firstChild) {
    const nsStyleBackground* result = firstChild->GetStyleBackground();
    nsIFrame* topFrame = aForFrame;

    if (firstChild->GetType() == nsLayoutAtoms::pageContentFrame) {
      topFrame = firstChild->GetFirstChild(nsnull);
      NS_ASSERTION(topFrame,
                   "nsPageContentFrame is missing a normal flow child");
      if (!topFrame) {
        return PR_FALSE;
      }
      NS_ASSERTION(topFrame->GetContent(),
                   "nsPageContentFrame child without content");
      result = topFrame->GetStyleBackground();
    }

    // Check if we need to do propagation from BODY rather than HTML.
    if (result->IsTransparent()) {
      nsIContent* content = topFrame->GetContent();
      if (content) {
        // Use |GetOwnerDoc| so it works during destruction.
        nsIDocument* document = content->GetOwnerDoc();
        nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(document);
        if (htmlDoc) {
          if (!document->IsCaseSensitive()) { // HTML, not XHTML
            nsCOMPtr<nsIDOMHTMLElement> body;
            htmlDoc->GetBody(getter_AddRefs(body));
            nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
            // We need to null check the body node (bug 118829) since
            // there are cases, thanks to the fix for bug 5569, where we
            // will reflow a document with no body.  In particular, if a
            // SCRIPT element in the head blocks the parser and then has a
            // SCRIPT that does "document.location.href = 'foo'", then
            // nsParser::Terminate will call |DidBuildModel| methods
            // through to the content sink, which will call |StartLayout|
            // and thus |InitialReflow| on the pres shell.  See bug 119351
            // for the ugly details.
            if (bodyContent) {
              nsIFrame *bodyFrame;
              nsresult rv = aPresContext->PresShell()->
                GetPrimaryFrameFor(bodyContent, &bodyFrame);
              if (NS_SUCCEEDED(rv) && bodyFrame)
                result = bodyFrame->GetStyleBackground();
            }
          }
        }
      }
    }

    *aBackground = result;
  } else {
    // This should always give transparent, so we'll fill it in with the
    // default color if needed.  This seems to happen a bit while a page is
    // being loaded.
    *aBackground = aForFrame->GetStyleBackground();
  }
  
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool FindElementBackground ( nsPresContext aPresContext,
nsIFrame aForFrame,
const nsStyleBackground **  aBackground 
) [inline]

Definition at line 2661 of file nsCSSRendering.cpp.

{
  nsIFrame *parentFrame = aForFrame->GetParent();
  // XXXldb We shouldn't have to null-check |parentFrame| here.
  if (parentFrame && IsCanvasFrame(aPresContext, parentFrame) == parentFrame) {
    // Check that we're really the root (rather than in another child list).
    nsIFrame *childFrame = parentFrame->GetFirstChild(nsnull);
    if (childFrame == aForFrame)
      return PR_FALSE; // Background was already drawn for the canvas.
  }

  *aBackground = aForFrame->GetStyleBackground();

  // Return true unless the frame is for a BODY element whose background
  // was propagated to the viewport.

  if (aForFrame->GetStyleContext()->GetPseudoType())
    return PR_TRUE; // A pseudo-element frame.

  nsIContent* content = aForFrame->GetContent();
  if (!content || !content->IsContentOfType(nsIContent::eHTML))
    return PR_TRUE;  // not frame for an HTML element

  if (!parentFrame)
    return PR_TRUE; // no parent to look at

  if (content->Tag() != nsHTMLAtoms::body)
    return PR_TRUE; // not frame for <BODY> element

  // We should only look at the <html> background if we're in an HTML document
  nsIDocument* document = content->GetOwnerDoc();
  nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(document);
  if (!htmlDoc)
    return PR_TRUE;

  if (document->IsCaseSensitive()) // XHTML, not HTML
    return PR_TRUE;
  
  const nsStyleBackground* htmlBG = parentFrame->GetStyleBackground();
  return !htmlBG->IsTransparent();
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool GetBGColorForHTMLElement ( nsPresContext aPresContext,
const nsStyleBackground *&  aBGColor 
)

Definition at line 1563 of file nsCSSRendering.cpp.

{
  NS_ASSERTION(aPresContext, "null params not allowed");
  PRBool result = PR_FALSE; // assume we did not find the HTML element

  nsIPresShell* shell = aPresContext->GetPresShell();
  if (shell) {
    nsIDocument *doc = shell->GetDocument();
    if (doc) {
      nsIContent *pContent;
      if ((pContent = doc->GetRootContent())) {
        // make sure that this is the HTML element
        nsIAtom *tag = pContent->Tag();
        NS_ASSERTION(tag, "Tag could not be retrieved from root content element");
        if (tag == nsHTMLAtoms::html ||
            tag == nsHTMLAtoms::body) {
          // use this guy's color
          nsIFrame *pFrame = nsnull;
          if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) &&
              pFrame) {
            nsStyleContext *pContext = pFrame->GetStyleContext();
            if (pContext) {
              const nsStyleBackground* color = pContext->GetStyleBackground();
              if (0 == (color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
                aBGColor = color;
                // set the reslt to TRUE to indicate we mapped the color
                result = PR_TRUE;
              }
            }// if context
          }// if frame
        }// if tag == html or body
#ifdef DEBUG
        else {
          printf( "Root Content is not HTML or BODY: cannot get bgColor of HTML or BODY\n");
        }
#endif
      }// if content
    }// if doc
  } // if shell

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool GetBorderColor ( const nsStyleColor aColor,
const nsStyleBorder aBorder,
PRUint8  aSide,
nscolor aColorVal,
nsBorderColors **  aCompositeColors = nsnull 
) [static]

Definition at line 1613 of file nsCSSRendering.cpp.

{
  PRBool transparent;
  PRBool foreground;

  if (aCompositeColors) {
    aBorder.GetCompositeColors(aSide, aCompositeColors);
    if (*aCompositeColors)
      return PR_TRUE;
  }

  aBorder.GetBorderColor(aSide, aColorVal, transparent, foreground);
  if (foreground)
    aColorVal = aColor->mColor;

  return !transparent;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void GetDashInfo ( nscoord  aBorderLength,
nscoord  aDashLength,
nscoord  aTwipsPerPixel,
PRInt32 aNumDashSpaces,
nscoord aStartDashLength,
nscoord aEndDashLength 
) [static]

Definition at line 4186 of file nsCSSRendering.cpp.

{
  aNumDashSpaces = 0;
  if (aStartDashLength + aDashLength + aEndDashLength >= aBorderLength) {
    aStartDashLength = aBorderLength;
    aEndDashLength = 0;
  }
  else {
    aNumDashSpaces = aBorderLength / (2 * aDashLength); // round down
    nscoord extra = aBorderLength - aStartDashLength - aEndDashLength - (((2 * aNumDashSpaces) - 1) * aDashLength);
    if (extra > 0) {
      nscoord half = RoundIntToPixel(extra / 2, aTwipsPerPixel);
      aStartDashLength += half;
      aEndDashLength += (extra - half);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void GetPath ( nsFloatPoint  aPoints[],
nsPoint  aPolyPath[],
PRInt32 aCurIndex,
ePathTypes  aPathType,
PRInt32 aC1Index,
float  aFrac 
) [static]


Given a qbezier path, convert it into a polygon path 3/26/99 dwc

Parameters:
aPoints-- an array of points to use for the path
aPolyPath-- an array of points containing the flattened polygon to use
aCurIndex-- the index that points to the last element of the array
aPathType-- what kind of path that should be returned
aFrac-- the inset amount for a eCalc type path

Definition at line 3904 of file nsCSSRendering.cpp.

{
  QBCurve thecurve;
  
  if (*aCurIndex >= MAXPOLYPATHSIZE)
    return;

  switch (aPathType) {
    case eOutside:
      thecurve.SetPoints(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      aC1Index = *aCurIndex;
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      aPolyPath[*aCurIndex].x = (nscoord)aPoints[3].x;
      aPolyPath[*aCurIndex].y = (nscoord)aPoints[3].y;
      (*aCurIndex)++;
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      thecurve.SetPoints(aPoints[3].x,aPoints[3].y,aPoints[4].x,aPoints[4].y,aPoints[5].x,aPoints[5].y);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      break;
    case eInside:
      thecurve.SetPoints(aPoints[6].x,aPoints[6].y,aPoints[7].x,aPoints[7].y,aPoints[8].x,aPoints[8].y);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      aPolyPath[*aCurIndex].x = (nscoord)aPoints[9].x;
      aPolyPath[*aCurIndex].y = (nscoord)aPoints[9].y;
      (*aCurIndex)++;
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      thecurve.SetPoints(aPoints[9].x,aPoints[9].y,aPoints[10].x,aPoints[10].y,aPoints[11].x,aPoints[11].y);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
     break;
    case eCalc:
      thecurve.SetPoints( (aPoints[0].x+aPoints[11].x)/2.0f,(aPoints[0].y+aPoints[11].y)/2.0f,
                          (aPoints[1].x+aPoints[10].x)/2.0f,(aPoints[1].y+aPoints[10].y)/2.0f,
                          (aPoints[2].x+aPoints[9].x)/2.0f,(aPoints[2].y+aPoints[9].y)/2.0f);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      aPolyPath[*aCurIndex].x = (nscoord)((aPoints[3].x+aPoints[8].x)/2.0f);
      aPolyPath[*aCurIndex].y = (nscoord)((aPoints[3].y+aPoints[8].y)/2.0f);
      (*aCurIndex)++;
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      thecurve.SetPoints( (aPoints[3].x+aPoints[8].x)/2.0f,(aPoints[3].y+aPoints[8].y)/2.0f,
                          (aPoints[4].x+aPoints[7].x)/2.0f,(aPoints[4].y+aPoints[7].y)/2.0f,
                          (aPoints[5].x+aPoints[6].x)/2.0f,(aPoints[5].y+aPoints[6].y)/2.0f);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      break;
    case eCalcRev:
      thecurve.SetPoints( (aPoints[5].x+aPoints[6].x)/2.0f,(aPoints[5].y+aPoints[6].y)/2.0f,
                          (aPoints[4].x+aPoints[7].x)/2.0f,(aPoints[4].y+aPoints[7].y)/2.0f,
                          (aPoints[3].x+aPoints[8].x)/2.0f,(aPoints[3].y+aPoints[8].y)/2.0f);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      aPolyPath[*aCurIndex].x = (nscoord)((aPoints[2].x+aPoints[9].x)/2.0f);
      aPolyPath[*aCurIndex].y = (nscoord)((aPoints[2].y+aPoints[9].y)/2.0f);
      (*aCurIndex)++;
      if (*aCurIndex >= MAXPOLYPATHSIZE)
        return;
      thecurve.SetPoints( (aPoints[2].x+aPoints[9].x)/2.0f,(aPoints[2].y+aPoints[9].y)/2.0f,
                          (aPoints[1].x+aPoints[10].x)/2.0f,(aPoints[1].y+aPoints[10].y)/2.0f,
                          (aPoints[0].x+aPoints[11].x)/2.0f,(aPoints[0].y+aPoints[11].y)/2.0f);
      thecurve.SubDivide(nsnull,aPolyPath,aCurIndex);
      break;
  } 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIScrollableFrame* GetRootScrollableFrame ( nsPresContext aPresContext,
nsIFrame aRootFrame 
) [static]

Definition at line 2483 of file nsCSSRendering.cpp.

{
  nsIScrollableFrame* scrollableFrame = nsnull;

  if (nsLayoutAtoms::viewportFrame == aRootFrame->GetType()) {
    nsIFrame* childFrame = aRootFrame->GetFirstChild(nsnull);

    if (childFrame) {
      if (nsLayoutAtoms::scrollFrame == childFrame->GetType()) {
        // Use this frame, even if we are using GFX frames for the
        // viewport, which contains another scroll frame below this
        // frame, since the GFX scrollport frame does not implement
        // nsIScrollableFrame.
        CallQueryInterface(childFrame, &scrollableFrame);
      }
    }
  }
#ifdef DEBUG
  else {
    NS_WARNING("aRootFrame is not a viewport frame");
  }
#endif // DEBUG

  return scrollableFrame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIFrame* IsCanvasFrame ( nsPresContext aPresContext,
nsIFrame aFrame 
) [inline]

|FindBackground| finds the correct style data to use to paint the background.

It is responsible for handling the following two statements in section 14.2 of CSS2:

The background of the box generated by the root element covers the entire canvas.

For HTML documents, however, we recommend that authors specify the background for the BODY element rather than the HTML element. User agents should observe the following precedence rules to fill in the background: if the value of the 'background' property for the HTML element is different from 'transparent' then use it, else use the value of the 'background' property for the BODY element. If the resulting value is 'transparent', the rendering is undefined.

Thus, in our implementation, it is responsible for ensuring that:

  • we paint the correct background on the |nsCanvasFrame|, |nsRootBoxFrame|, or |nsPageFrame|,
  • we don't paint the background on the root element, and
  • we don't paint the background on the BODY element in some cases, and for SGML-based HTML documents only.

|FindBackground| returns true if a background should be painted, and the resulting style context to use for the background information will be filled in to |aBackground|. It fills in a boolean indicating whether the frame is the canvas frame to allow PaintBackground to ensure that it always paints something non-transparent for the canvas.

Definition at line 2575 of file nsCSSRendering.cpp.

{
  nsIAtom* frameType = aFrame->GetType();
  if (frameType == nsLayoutAtoms::canvasFrame ||
      frameType == nsLayoutAtoms::rootFrame ||
      frameType == nsLayoutAtoms::pageFrame) {
    return aFrame;
  } else if (frameType == nsLayoutAtoms::viewportFrame) {
    nsIFrame* firstChild = aFrame->GetFirstChild(nsnull);
    if (firstChild) {
      return firstChild;
    }
  }
  
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nscoord RoundFloatToPixel ( float  aValue,
nscoord  aTwipsPerPixel,
PRBool  aRoundDown = PR_FALSE 
) [static]

Definition at line 4096 of file nsCSSRendering.cpp.

{
  return RoundIntToPixel(NSToCoordRound(aValue), aTwipsPerPixel, aRoundDown);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nscoord RoundIntToPixel ( nscoord  aValue,
nscoord  aTwipsPerPixel,
PRBool  aRoundDown = PR_FALSE 
) [static]

Definition at line 4080 of file nsCSSRendering.cpp.

{
  if (aTwipsPerPixel <= 0) 
    // We must be rendering to a device that has a resolution greater than Twips! 
    // In that case, aValue is as accurate as it's going to get.
    return aValue; 

  nscoord halfPixel = NSToCoordRound(aTwipsPerPixel / 2.0f);
  nscoord extra = aValue % aTwipsPerPixel;
  nscoord finalValue = (!aRoundDown && (extra >= halfPixel)) ? aValue + (aTwipsPerPixel - extra) : aValue - extra;
  return finalValue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetPoly ( const nsRect aRect,
nsPoint poly 
) [static]

Definition at line 4104 of file nsCSSRendering.cpp.

{
  poly[0].x = aRect.x;
  poly[0].y = aRect.y;
  poly[1].x = aRect.x + aRect.width;
  poly[1].y = aRect.y;
  poly[2].x = aRect.x + aRect.width;
  poly[2].y = aRect.y + aRect.height;
  poly[3].x = aRect.x;
  poly[3].y = aRect.y + aRect.height;
  poly[4].x = aRect.x;
  poly[4].y = aRect.y;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 194 of file nsCSSRendering.cpp.