added PainBorderSegments

git-svn-id: svn://10.0.0.236/trunk@16618 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
buster%netscape.com 1998-12-17 22:58:51 +00:00
parent 4f61c6e05f
commit 32c13321e7
4 changed files with 242 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "nsIViewManager.h"
#include "nsIPresShell.h"
#include "nsIFrameImageLoader.h"
#include "nsIStyleContext.h"
#include "nsGlobalVariables.h"
#define BORDER_FULL 0 //entire side
@ -913,6 +914,7 @@ void nsCSSRendering::DrawDashedSides(PRIntn startSide,
skippedSide = PR_FALSE;
}
}
// XXX improve this to constrain rendering to the damaged area
void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
@ -983,6 +985,104 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext,
}
}
// XXX improve this to constrain rendering to the damaged area
void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBounds,
nsBorderEdges * aBorderEdges,
PRIntn aSkipSides,
nsRect* aGap)
{
//PRIntn cnt;
PRBool printing = nsGlobalVariables::Instance()->GetPrinting(&aPresContext);
if (nsnull==aBorderEdges) { // Empty border segments
return;
}
// Turn off rendering for all of the zero sized sides
if (0 == aBorderEdges->mMaxBorderWidth.top)
aSkipSides |= (1 << NS_SIDE_TOP);
if (0 == aBorderEdges->mMaxBorderWidth.right)
aSkipSides |= (1 << NS_SIDE_RIGHT);
if (0 == aBorderEdges->mMaxBorderWidth.bottom)
aSkipSides |= (1 << NS_SIDE_BOTTOM);
if (0 == aBorderEdges->mMaxBorderWidth.left)
aSkipSides |= (1 << NS_SIDE_LEFT);
nsRect inside(aBounds);
nsRect outside(inside);
outside.Deflate(aBorderEdges->mMaxBorderWidth);
/* XXX ignoring dotted and dashed for now */
#if 0
//see if any sides are dotted or dashed
for (cnt = 0; cnt < 4; cnt++) {
if ((aStyle.GetBorderStyle(cnt) == NS_STYLE_BORDER_STYLE_DOTTED) ||
(aStyle.GetBorderStyle(cnt) == NS_STYLE_BORDER_STYLE_DASHED)) {
break;
}
}
if (cnt < 4) {
DrawDashedSides(cnt, aRenderingContext,aStyle,
inside, outside, aSkipSides, aGap);
}
#endif //XXX
// Draw all the other sides
nscoord twipsPerPixel = (nscoord)aPresContext.GetPixelsToTwips();
if (0 == (aSkipSides & (1<<NS_SIDE_TOP))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_TOP].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_TOP].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_TOP,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_LEFT))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_LEFT].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_LEFT].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_LEFT,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_BOTTOM))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_BOTTOM].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_BOTTOM].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_LEFT,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_RIGHT))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_RIGHT].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_RIGHT].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_LEFT,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
}
//----------------------------------------------------------------------
static void

View File

@ -41,6 +41,27 @@ public:
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Just like PaintBorder, but takes as input a list of border segments
* rather than a single border style. Useful for any object that needs to
* draw a border where an edge is not necessarily homogenous.
* Render the border for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip
* when rendering. If 0 then no sides are skipped.
*
* Both aDirtyRect and aBounds are in the local coordinate space
* of aForFrame
*/
static void PaintBorderEdges(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBounds,
nsBorderEdges * aBorderEdges,
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Render the background for an element using css rendering rules
* for backgrounds.

View File

@ -25,6 +25,7 @@
#include "nsIViewManager.h"
#include "nsIPresShell.h"
#include "nsIFrameImageLoader.h"
#include "nsIStyleContext.h"
#include "nsGlobalVariables.h"
#define BORDER_FULL 0 //entire side
@ -913,6 +914,7 @@ void nsCSSRendering::DrawDashedSides(PRIntn startSide,
skippedSide = PR_FALSE;
}
}
// XXX improve this to constrain rendering to the damaged area
void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
@ -983,6 +985,104 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext,
}
}
// XXX improve this to constrain rendering to the damaged area
void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBounds,
nsBorderEdges * aBorderEdges,
PRIntn aSkipSides,
nsRect* aGap)
{
//PRIntn cnt;
PRBool printing = nsGlobalVariables::Instance()->GetPrinting(&aPresContext);
if (nsnull==aBorderEdges) { // Empty border segments
return;
}
// Turn off rendering for all of the zero sized sides
if (0 == aBorderEdges->mMaxBorderWidth.top)
aSkipSides |= (1 << NS_SIDE_TOP);
if (0 == aBorderEdges->mMaxBorderWidth.right)
aSkipSides |= (1 << NS_SIDE_RIGHT);
if (0 == aBorderEdges->mMaxBorderWidth.bottom)
aSkipSides |= (1 << NS_SIDE_BOTTOM);
if (0 == aBorderEdges->mMaxBorderWidth.left)
aSkipSides |= (1 << NS_SIDE_LEFT);
nsRect inside(aBounds);
nsRect outside(inside);
outside.Deflate(aBorderEdges->mMaxBorderWidth);
/* XXX ignoring dotted and dashed for now */
#if 0
//see if any sides are dotted or dashed
for (cnt = 0; cnt < 4; cnt++) {
if ((aStyle.GetBorderStyle(cnt) == NS_STYLE_BORDER_STYLE_DOTTED) ||
(aStyle.GetBorderStyle(cnt) == NS_STYLE_BORDER_STYLE_DASHED)) {
break;
}
}
if (cnt < 4) {
DrawDashedSides(cnt, aRenderingContext,aStyle,
inside, outside, aSkipSides, aGap);
}
#endif //XXX
// Draw all the other sides
nscoord twipsPerPixel = (nscoord)aPresContext.GetPixelsToTwips();
if (0 == (aSkipSides & (1<<NS_SIDE_TOP))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_TOP].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_TOP].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_TOP,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_LEFT))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_LEFT].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_LEFT].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_LEFT,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_BOTTOM))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_BOTTOM].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_BOTTOM].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_LEFT,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_RIGHT))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_RIGHT].Count();
PRInt32 i;
for (i=0; i<segmentCount; i++)
{
nsBorderEdge * borderEdge = (nsBorderEdge *)(aBorderEdges->mEdges[NS_SIDE_RIGHT].ElementAt(i));
DrawSide(aRenderingContext, NS_SIDE_LEFT,
borderEdge->mStyle,
borderEdge->mColor,
inside, outside, printing, twipsPerPixel, aGap);
}
}
}
//----------------------------------------------------------------------
static void

View File

@ -41,6 +41,27 @@ public:
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Just like PaintBorder, but takes as input a list of border segments
* rather than a single border style. Useful for any object that needs to
* draw a border where an edge is not necessarily homogenous.
* Render the border for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip
* when rendering. If 0 then no sides are skipped.
*
* Both aDirtyRect and aBounds are in the local coordinate space
* of aForFrame
*/
static void PaintBorderEdges(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBounds,
nsBorderEdges * aBorderEdges,
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Render the background for an element using css rendering rules
* for backgrounds.